Hi, I am currently trying to bundle an application that controls scientific equipment. One particular dependency (`pyfits`) causes a crash when trying to launch an `.exe` built in one-dir mode. The crash happens when the `pyfits` module tries to load mscvrt, using `ctypes`, after some checks (ie: it uses `ctypes.utils.find_mscvrt()` and a variable).
I have reproduced this issue using a minimal script. The program crashes with windows error R6034. MSVCR are bundled in the dist, with the version number found in the accompanying manifest file. I've tried swapping arround the `win_no_prefer_redirects` and `win_private_assemblies` flags without any success. I have tried replacing the manifest files found in `dist\` with the one from `build\` with no success, as suggested here: http://stackoverflow.com/questions/17468135/pyinstaller-and-r6034-error I am running windows 10 64, python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)], pyinstaller 3.2 Any help on the matter is very welcome. The script: #!python2 # try loading mscvrt using ctypes.util. For bug tracking. from ctypes.util import find_msvcrt, find_library from ctypes import cdll mscvrt_dll = find_msvcrt() print("mscvrt_dll is", mscvrt_dll) print("find_library(mscvrt_dll)", find_library(mscvrt_dll)) mscvrt = cdll.LoadLibrary(mscvrt_dll) The build output (powershell running a venv): (axis)PS streakgui> pyinstaller --clean -dy .\try_load_mscvrt.spec 92 INFO: PyInstaller: 3.2 92 INFO: Python: 2.7.10 94 INFO: Platform: Windows-8-6.2.9200 95 INFO: UPX is not available. 95 INFO: Removing temporary files and cleaning cache in C:\Users\Samuel\AppData\Roaming\pyinstaller 96 INFO: Extending PYTHONPATH with paths ['C:\\workzone\\src', 'C:\\workzone\\src\\streakgui'] 98 INFO: checking Analysis 98 INFO: Building Analysis because out00-Analysis.toc is non existent 98 INFO: Initializing module dependency graph... 101 INFO: Initializing module graph hooks... 138 INFO: running Analysis out00-Analysis.toc 141 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable required by c:\users\samuel\.virtualenvs\axis\scripts\python.exe 226 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 226 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest 229 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_f4813cfaf6543c37.manifest 313 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.9177_none ... 313 INFO: Found manifest C:\WINDOWS\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9.manifest 315 INFO: Searching for file msvcr90.dll 315 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcr90.dll 315 INFO: Searching for file msvcp90.dll 316 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcp90.dll 316 INFO: Searching for file msvcm90.dll 316 INFO: Found file C:\WINDOWS\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_5093cc7abcb795e9\msvcm90.dll 401 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 402 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest 404 INFO: Found C:\WINDOWS\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.9177_none_f4813cfaf6543c37.manifest 404 INFO: Adding redirect Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177) 4036 INFO: Caching module hooks... 4042 INFO: Analyzing try_load_mscvrt.py 4967 INFO: Loading module hooks... 4969 INFO: Loading module hook "hook-encodings.py"... 5285 INFO: Looking for ctypes DLLs 5286 INFO: Analyzing run-time hooks ... 5292 INFO: Looking for dynamic libraries 6759 INFO: Looking for eggs 6759 INFO: Using Python library C:\WINDOWS\system32\python27.dll 6759 INFO: Found binding redirects: [BindingRedirect(name=u'Microsoft.VC90.CRT', language=None, arch=u'x86', oldVersion=(9, 0, 21022, 8), newVersion=(9, 0, 30729, 9177), publicKeyToken= u'1fc8b3b9a1e18e3b')] 6766 INFO: Warnings written to C:\workzone\src\streakgui\build\try_load_mscvrt\warntry_load_mscvrt.txt 6849 INFO: checking PYZ 6851 INFO: Building PYZ because out00-PYZ.toc is non existent 6851 INFO: Building PYZ (ZlibArchive) C:\workzone\src\streakgui\build\try_load_mscvrt\out00-PYZ.pyz 7246 INFO: checking PKG 7246 INFO: Building PKG because out00-PKG.toc is non existent 7246 INFO: Building PKG (CArchive) out00-PKG.pkg 7407 INFO: Bootloader c:\users\samuel\.virtualenvs\axis\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run_d.exe 7407 INFO: checking EXE 7407 INFO: Building EXE because out00-EXE.toc is non existent 7407 INFO: Building EXE from out00-EXE.toc 7408 INFO: Appending archive to EXE C:\workzone\src\streakgui\build\try_load_mscvrt\try_load_mscvrt.exe 7507 INFO: checking COLLECT 7509 INFO: Building COLLECT because out00-COLLECT.toc is non existent 7509 INFO: Removing dir C:\workzone\src\streakgui\dist\try_load_mscvrt 7513 INFO: Building COLLECT out00-COLLECT.toc 7546 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177) 7720 INFO: Redirecting Microsoft.VC90.CRT version (9, 0, 21022, 8) -> (9, 0, 30729, 9177) 7721 INFO: Updating manifest in C:\Users\Samuel\AppData\Roaming\pyinstaller\bincache00_py27_32bit\python27.dll 7721 INFO: Updating resource type 24 name 2 language 1033 Launching the resulting file results in the display of this error popup message: Runtime Error! Program: C:\work... R6034 An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information. And the console log: PS streakgui> .\dist\try_load_mscvrt\try_load_mscvrt.exe PyInstaller Bootloader 3.x LOADER: executable is C:\workzone\src\streakgui\dist\try_load_mscvrt\try_load_mscvrt.exe LOADER: homepath is C:\workzone\src\streakgui\dist\try_load_mscvrt LOADER: _MEIPASS2 is NULL LOADER: archivename is C:\workzone\src\streakgui\dist\try_load_mscvrt\try_load_mscvrt.exe LOADER: No need to extract files to run; setting extractionpath to homepath LOADER: SetDllDirectory(C:\workzone\src\streakgui\dist\try_load_mscvrt) LOADER: Already in the child - running user's code. LOADER: Python library: C:\workzone\src\streakgui\dist\try_load_mscvrt\python27.dll LOADER: Loaded functions from Python library. LOADER: Manipulating environment (sys.path, sys.prefix) LOADER: sys.prefix is C:\workzone\src\STREAK~1\dist\TRY_LO~1 LOADER: Setting runtime options LOADER: Initializing python LOADER: Overriding Python's sys.path LOADER: Post-init sys.path is C:\workzone\src\streakgui\dist\try_load_mscvrt LOADER: Setting sys.argv LOADER: setting sys._MEIPASS LOADER: importing modules from CArchive LOADER: extracted struct LOADER: callfunction returned... LOADER: extracted pyimod01_os_path LOADER: callfunction returned... LOADER: extracted pyimod02_archive LOADER: callfunction returned... LOADER: extracted pyimod03_importers LOADER: callfunction returned... LOADER: Installing PYZ archive with Python modules. LOADER: PYZ archive: out00-PYZ.pyz LOADER: Running pyiboot01_bootstrap.py LOADER: Running try_load_mscvrt.py ('mscvrt_dll is', 'msvcr90.dll') ('find_library(mscvrt_dll)', None) Traceback (most recent call last): File "streakgui\try_load_mscvrt.py", line 9, in <module> File "ctypes\__init__.py", line 443, in LoadLibrary File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 131, in __init__ File "ctypes\__init__.py", line 365, in __init__ WindowsError: [Error 1114] Une routine dÆinitialisation dÆune bibliothΦque de liens dynamiques (DLL) a Θchou Failed to execute script try_load_mscvrt LOADER: OK. LOADER: Cleaning up Python interpreter. -- You received this message because you are subscribed to the Google Groups "PyInstaller" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyinstaller. For more options, visit https://groups.google.com/d/optout.
