5

I use pyinstaller to create an exe out of my script file. My script is mysql_backup.py

I run

pyinstaller --onefile mysql_backup.py

Output

52 INFO: wrote
C:\Users\vlahopou\PycharmProjects\TestClient\mysql_backup.spec
73 INFO: Testing for ability to set icons, version resources...
104 INFO: ... resource update available
105 INFO: UPX is not available.
128 INFO: Processing hook hook-os
219 INFO: Processing hook hook-time
223 INFO: Processing hook hook-cPickle
276 INFO: Processing hook hook-_sre
368 INFO: Processing hook hook-cStringIO
446 INFO: Processing hook hook-encodings
457 INFO: Processing hook hook-codecs
831 INFO: Extending PYTHONPATH with C:\Users\vlahopou\PycharmProjects\TestClient
831 INFO: checking Analysis
832 INFO: building Analysis because out00-Analysis.toc non existent
832 INFO: running Analysis out00-Analysis.toc
832 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
902 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
902 WARNING: Assembly not found
902 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
996 INFO: Searching for assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
996 WARNING: Assembly not found
996 ERROR: Assembly amd64_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
1075 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\_pyi_bootstrap.py
1088 INFO: Processing hook hook-os
1101 INFO: Processing hook hook-site
1117 INFO: Processing hook hook-encodings
1213 INFO: Processing hook hook-time
1217 INFO: Processing hook hook-cPickle
1270 INFO: Processing hook hook-_sre
1375 INFO: Processing hook hook-cStringIO
1470 INFO: Processing hook hook-codecs
1900 INFO: Processing hook hook-pydoc
2013 INFO: Processing hook hook-email
2056 INFO: Processing hook hook-httplib
2092 INFO: Processing hook hook-email.message
2148 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_importers.py
2181 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_archive.py
2210 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_carchive.py
2242 INFO: Analyzing C:\Python27\lib\site-packages\PyInstaller\loader\pyi_os_path.py
2246 INFO: Analyzing mysql_backup.py
2328 INFO: Processing hook hook-xml
2427 INFO: Processing hook hook-xml.sax
2471 INFO: Processing hook hook-pyexpat
2474 INFO: Hidden import 'codecs' has been found otherwise
2474 INFO: Hidden import 'encodings' has been found otherwise
2474 INFO: Looking for run-time hooks
2746 INFO: Using Python library C:\WINDOWS\system32\python27.dll
2846 INFO: Warnings written to C:\Users\vlahopou\PycharmProjects\TestClient\build\mysql_backup\warnmysql_backup.txt
2858 INFO: checking PYZ
2858 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2858 INFO: building PYZ (ZlibArchive) out00-PYZ.toc
3756 INFO: checking PKG
3756 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
3757 INFO: building PKG (CArchive) out00-PKG.pkg
5257 INFO: checking EXE
5259 INFO: rebuilding out00-EXE.toc because mysql_backup.exe missing
5259 INFO: building EXE from out00-EXE.toc
5262 INFO: Appending archive to EXE C:\Users\vlahopou\PycharmProjects\TestClient\dist\mysql_backup.exe

The problems comes when I try to execute this on a machine that didn't have python installed. I want to be able to extract an exe with python bundled so that it doesn't have any dependencies when user wants to run it. Is it possible with pyinstaller? My file runs normally on the machine that produced it.

DEBUG INFO

C:\>mysql_backup.exe
LOADER: executable is C:\mysql_backup.exe
LOADER: homepath is C:
LOADER: _MEIPASS2 is NULL
LOADER: archivename is C:\mysql_backup.exe
LOADER: Extracting binaries
LOADER: Executing self as child
LOADER: Setting up to run child
LOADER: Creating child process
LOADER: Waiting for child process to finish...
LOADER: executable is C:\mysql_backup.exe
LOADER: homepath is C:
LOADER: _MEIPASS2 is C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882
LOADER: archivename is C:\mysql_backup.exe
LOADER: Already in the child - running user's code.
LOADER: manifestpath: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882\mysql_backup.exe.manifest
LOADER: Error activating the context
LOADER: Python library: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882\python27.dll
Error loading Python DLL: C:\Users\ADMINI~1\AppData\Local\Temp\2\_MEI21882\python27.dll (error code 14001)
LOADER: Deactivating activation context
LOADER: Releasing activation context
LOADER: Done
LOADER: Back to parent
LOADER: Doing cleanup
LOADER: Freeing archive status for C:\mysql_backup.exe
EmptyMan
  • 297
  • 1
  • 4
  • 25
Apostolos
  • 7,763
  • 17
  • 80
  • 150
  • sounds like the VC runtime that goes with that python version isn't installed. you have it, because you have python installed. – Corley Brigman Sep 08 '15 at 13:41
  • Could you ellaborate a bit more on that?Also forgot to mention that I am trying to run my exe on a vm of win server 2008 while pyinstaller was executed on win7 machine. – Apostolos Sep 08 '15 at 13:47
  • i have used py2exe, not pyinstaller yet (but I need to). python requires a VC runtime DLL to run; an attached manifest is supposed to tell it which runtime to load. you could try installing this on the target machine just to verify that it's your issue: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29 – Corley Brigman Sep 08 '15 at 15:09
  • but pyinstaller is supposed to attach that to the file. the errors after this line: `INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable` - imply that it's not finding it, so it's not making it into your file. unfortunately, that's as far as I can help - not sure why pyinstaller isn't including it. – Corley Brigman Sep 08 '15 at 15:11
  • Tested it in an environment with no python installed not a vm and worked(no python was on his path no python in c:\)... It works on my pc too but I guess it's because I have python installed – Apostolos Sep 08 '15 at 16:24
  • lots of programs use the VC runtimes... if you pick a random machine, it may already have it loaded. another machine may not. best way is to try installing the runtime on the failing machine and see if it starts working. if it does, you need to figure out how to help pyinstaller find the files, as they are supposed to be included in the output exe. – Corley Brigman Sep 08 '15 at 17:07

1 Answers1

12

I had a similar problem, with exactly the same error code 14001 when I deployed my executable, and I solved it with this set of parameters:

pyinstaller --clean --win-private-assemblies -F <python files>

From the help description:

--clean             Clean PyInstaller cache and remove temporary files
                    before building.

--win-private-assemblies
                    Any Shared Assemblies bundled into the application
                    will be changed into Private Assemblies. This means
                    the exact versions of these assemblies will always be
                    used, and any newer versions installed on user
                    machines at the system level will be ignored.

-F, --onefile       Create a one-file bundled executable.
marcelo.guedes
  • 482
  • 5
  • 12
  • See also this issue in github for more information: https://github.com/pyinstaller/pyinstaller/issues/1291#issuecomment-146557688 – maggie Aug 08 '18 at 07:39