How to point pyinstaller to the right versions of MSVC?90.dll? - python-2.7

I have a python application that I am trying to build as a pyinstaller distributable. A similar script builds successfully on Linux.
I am building it on Windows 7 x64, but want to build 32-bit binary for better compatibility, so I am using 32-bit python-2.7. Among my dependencies are matplotlib and pyside which require MSVC. I install a package called VCForPython27 from Microsoft.
I run into an error when I run my pyinstaller script. I get the following message:
1250 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
7428 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
7428 WARNING: Assembly not found
7428 ERROR: Assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
7475 WARNING: lib not found: MSVCR90.dll dependency of C:\Python27\python.exe
7553 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
7553 WARNING: Assembly not found
7553 ERROR: Assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
7662 WARNING: lib not found: MSVCR90.dll dependency of C:\Windows\system32\python27.dll
7662 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\_pyi_boots
There are multiple messages like that about both the files MSVCP90.dll and MSVCR90.dll
I can see that I have a folder C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2 that contains versions of both files.
This mismatch occurs both when I install my python packages from Christoph Gohlke's page and with pip (except for matplotlib, which I can't install with pip because of missing dependencies).
Strangely enough pyinstaller makes a binary. Yet, when I try to run it I get a popup saying:
WARNING: file already exists but should not:
C:\Users\Martin\AppData\Local\Temp\_MEI34922\Include\pyconfig.h
Does anyone know how I can do any of the following:
Install the precious x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none assembly? Where can I take this specific version from?
Tell python to look for the other version (x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2)?
Solve the pyconfig.h unwanted presence issue? Doesn't seem to lead anywhere, but I thought I should try it too.
Find another way to build my code to a binary? It's a complicated code, running external binaries, but if I have to I will try py2exe, not sure that it would be any better though.

The redistributable package that contains version 9.0.21022.8 of msvcr90.dll and msvcp90.dll can be downloaded from the Microsoft website here. This will help PyInstaller to find the versions it wants and include them with the resulting executable.
Interestingly enough, I'm able to run the executable compiled by PyInstaller with redistributable version 9.0.30729.6161 installed, it just won't package these dlls. I tried to copy the msvc*90.dll's into the dist directory, even tried creating and modifying manifest files, but I would still get an error from python27.dll in the end. Installing any version of VC++ redistributable would fix the issue, but then my package wouldn't be self-containing. I wish I understood what exactly is going on here better...

Related

Error on libcurl.dll when using GDAL of OSGeo4W in Django

I'm trying to install GeoDjango in my Django project and got weird errors with GDAL.
Following Django documentation, I installed GDAL, GEOS, PROJ using OSGeo4W64, for specific, these are packages I selected to install on OSGeo4W64 setup:
gdal v2.3.2-2
geos v3.7.0-1
proj v5.2.0-1
I also set my environment variables as documented.
What error I got
At first when I started my Django project (using runserver), python tried to look for gdal202.dll and raised error Entry Point Not Found:
The procedure entry point sqlite3_column_origin_name could not be
located in the dynamic link library ...\osgeo4w64\bin\gdal202.dll
And one more error Ordinal Not Found with libcurl.dll (installed by OSGeo4W as dependencies):
The ordinal 361 could not be located in the dynamic link library
..\osgeo4w64\bin\libcurl.dll
and python raised error:
[WinError 182] The operating system cannot run %1
What I did
I fixed the first error by downgrade gdal version to gdal201.dll but still can not figure out how to solve the second error.
I tried download the latest Windows binary version of libcurl and replaced with but then I got another error raised by python:
[WinError 126] The specified module could not be found
I also checked for arch of my curl binary is x64 (the same as my python and OSGeo4W).
Hope someone one can help, thanks so much.
On Windows w/ Django and PyCharm, I began to receive the same error as one of your earlier ones, as described below:
The procedure entry point sqlite3_column_origin_name could not be located in the dynamic link library C:\Program Files\GDAL\gdal203.dll
Short-story solution that worked for me
Renamed: "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\DLLs\sqlite3.dll" to sqlite3.dll.bak
I used two tools to help me resolve this
Dependencies
Process Explorer 64
Steps used to correct
Use Dependencies to load up gdal203.dll and look for which DLL is used for sqlite3_column_origin_name
Used Process Explorer to determine which sqlite3.dll was being loaded into memory (welcome to DLL-hell). In my case it was in "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\DLLs"
Used Dependencies to examine the sqlite3.dll from Visual Studio
Exited PyCharm and renamed the Visual Studio DLL sqlite3.dll.bak to force it to load up the one according to my PATH order. Who knows what else I may have unintentionally broke by doing this. Future-me might hate me for this.
Starting with a new install of Windows 10, followed by installing PyCharm, Django, GeoDjango... it won't work without substantial troubleshooting in my experience. I think partly from DLL-hell and partly due to PyCharm's runnerw64.exe used to hook in the debugger.

GDB on NetBeans 8.2 not starting (Windows)

I've successfully installed NetBeans 8.2 on my system. I've also installed MinGW and MSYS to make it compile C/C++ projects and it works flawlessly. The problem is that whenever I try to debug a program it gives me two errors:
Selected console type is not supported in your configuration, using
External terminal instead
and
GDB has unexpectedly stopped with return -1.073.741.701
and GDB is stuck loading until i press Cancel.
I noticed that if I go to C:\MinGW\bin\gdb.exe it says that the application cannot be started (Error code: 0xc00007b).
Maybe that's because I followed the official tutorial for installing MinGW and MSYS, but I wasn't able to install GDB correctly because point 15 says:
Unzip the gdb-7.0-2-mingw32-bin.tar.gz to your C:\MinGW directory so
that the gdb executable is installed into your C:\MinGW\bin directory.
but if I unzip the files, there are bin and share directories (which overlap with the existing ones), so I chose to cancel.
I could have found the issue, but I'm not sure. I ran Dependency Walker on gdb.exe and it reds out ZLIB1.DLL and KERNEL32.DLL. Do I need the 32-bit version of them? If so, where can I find the downloads?
Screenshot:
Not unzipping the files is almost definitely the problem. There is probably a dependency that doesn't, causing a runtime error.
Problem solved: as I mentioned in my edit, the problem was the 64-bit version of ZLIB1.dll, so I downloaded the 32-bit version and put it inside C:\MinGW\bin. Now everything works perfectly. Thanks to #bremen_matt for suggesting me that it was a dependency issue.

pyinstaller 3.2 build pyqt4/python2.7 to onefile exe, can not run missing msvcr100.dll?

As title,
Build successful, but the exe can't run. can not found msvcr100.dll.
I can put msvcr100.dll with exe in the same dir, the exe can run.
But I just want only one exe file.
Anyone know how to do?
Has solved. This is a bug of pyinstaller3.2, the new in the git has solved this bug. Down the newest source in the github, erverything works fine.
Has solved. This is a bug of pyinstaller3.2, the new one in the git has solved this bug. Down the newest source in the GitHub, everything works fine.
This is correct, I cant tell you how much that answer helped me out. I have been trying to build a single exe Exploit to execute on Windows XP with-out it crashing for my OSCP Labs/Exam. I followed so many tutorials and nothing seems to work. I was able to build the EXE but could not get it to run under a single EXE.
If anyone who reads this is getting "This Program cannot be run in DOS mode" try running it from another machine with the same build (Windows XP). There is not much info out there on how to solve that from a Reverse Shell on a End Of Life Operating System using an EXE exploit built with Pyinstaller. (Lots of Trial and Error and determination)
Microsoft Visual C++ 2008 Redistributable Package (or some other version depending on python version) is needed in any case, python27.dll requires it
I was also receiving an error about msvcr100.dll when ran from the GUI on my build machine(WinXP SP2). This is corrected in the 3.3 Dev version on GitHub.
I installed the C++ 2008 Package but this didn't solve my problem when I re-built the EXE, the 3.3 Dev Pyinstaller was the solution.
What I did was:
Zip down the Dev version of Pyinstaller 3.3 Dev(GitHub) is the newest for 11/14/16 that I could tell. Make sure you have Python 2.7.x (I used 2.7.11) and pywin32 installed that matches (Python 2.7.x) version. (And it does matter if its 64-bit or 32-bit) Use the setup.py to install Pyinstaller, make sure you do not have a previous version already installed, if so use pip or etc. to remove. I installed with pip first and this was my whole issue.
I was able to get all of my 32-bit Single EXE Exploits to run on 64-bit/32-bit Windows machines up to Windows 10.
Once that is completed, make sure Pyinstaller is in your $PATH and follow the standard tutorials on creating a --onefile EXE. Copy to your Windows Target machine and it should work with-out error. I did not need to pull any dependencies over but you may have to include some with the --hidden command. Its greatly detailed in the Pyinstaller documentation on how to include hidden .dlls
If this still doesn't work for you try using py2exe. Its a little more complicated but it your determined you will figure it out.
If you have code written in python 2.x.x and 3.x.x you can have multiple environments of Python and have Pyinstaller installed in each. This is in the documentation as well.
Thank you jim ying. Your 2 sentence answer was exactly what I needed.

Having trouble getting Python to recognize location of vcvarsall.bat

I was trying to install RandomWords which requires ujson, at some point in the installation I received the following notification: "error: Unable to find vcvarsall.bat" I searched here, on stackoverflow, and came across some answers as the to root of this problem. In this answer https://stackoverflow.com/a/8705722, near the end, the OP pointed out that Microsoft had released a C++ compiler package for Python 2.7 (http://www.microsoft.com/en-us/download/details.aspx?id=44266).
I installed this package but still haven't had any success in installing ujson. So far I've tried the following:
Adding the location of vcvarsall.bat to the path environment variable
Manually tried loading the VC++ compiler's environment into the session by executing vcvars64.bat (aI've tried vcvars32.bat as well) as recommended here: https://stackoverflow.com/a/18045219
I've also tried installing the compilers found in "Windows SDK for Windows 7 and .NET Framework 3.5 SP1" found here: http://www.microsoft.com/en-us/download/details.aspx?id=3138
Not sure where to go from here, any suggestions/help would be greatly appreciated.
For reference here's some relevant specs:
Windows 8.1 (64-bit)
Python 2.7 (64-bit)
I've been trying to install said package using pip from the command prompt (e.g. '> pip install ujson')
I've uninstalled all the C++ compiler packages I've tried except this one: http://www.microsoft.com/en-us/download/details.aspx?id=44266
Really don't feel like installing mingw, but I'll try it if it seems like it's the only solution.
-UPDATE-
I ended up modifying "msvc9compiler.py" and manually setting the location of vcvarsall.bat by setting the value of the vcvarsall variable to the location of that batch file. Everything compiled fine but this is not a recommended solution. I'm pretty sure the compiler version I have matches the one python 2.7 uses, but as mentioned in an answer, in another question on this topic, if these don't match it can cause problems since "the compilers will probably have incompatible C runtime libraries."

The procedure entry point _gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll

I have installed Codeblocks 13.12 with MinGW and I try to run an OpenCV application. I compiled it with no problems but when I try to run it throws the following error:
The procedure entry point _gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll
I checked on stackoverflow questions with similar problems and everyone was pointing to copying the MinGW dll file to the application folder. I did that and then I had this error:
This application has failed to start because libgcc_s_dw2-1.dll was not found. Reinstalling the application may fix this problem.
So I copied that dll too. And then I had the following error:
This application has failed to start because libgcc_s_sjij-1.dll was not found. Reinstalling the application may fix this problem.
I copied this dll too and then I had the first error about the missing __gxx_personality_v0 entry point all over again.
This is an ABI incompatibility. You are linking code built with two different toolchains (one with dw2 exception handling and one with sjlj).
Either rebuild everything with the same toolchain, or find yourself a matching toolchain:
MinGW-w64 installer is located here. You can select various variants when you run it.
Use MSYS2, which comes with a repository containing a variety of packages already compiled for you (including OpenCV). It comes with the pacman package manager (ported from Arch Linux). It provides a Unix shell environment for your convenience, but the toolchains can be used outside of the shell itself.