Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when creating executable file with pyinstaller

I'm trying to create an exe for my python script using pyinstaller each time it runs into errors which can be found in a pastebin here.

Also when I double click the exe file it shows this error:

C:Users\Afro\AppData\Local\Temp_MEI51322\VCRUNTIME140.dll is either not designed to run on windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc000007b

and then this:

Error loading Python DLL: C:\Users\Afro\AppData\Local\Temp_MEI51322\python35.dll(error code 193)

what's wrong, please?

like image 968
HackAfro Avatar asked Aug 07 '16 07:08

HackAfro


People also ask

Why is the .EXE file created by PyInstaller not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

How do I fix PyInstaller not working?

To Solve 'pyinstaller' is not recognized as an internal or external command operable program or batch file Error You just need to add python script in your path to solve this error.

Do you need Python to run a PyInstaller EXE?

They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for: a different OS.


2 Answers

I was haunted with similar issue. It might be that in your case UPX is breaking vcruntime140.dll. Solution to this is turning off UPX, so just add --noupx to your pyinstaller call.

pyinstaller --noupx --onedir --onefile --windowed get.py

Long explanation here: UPX breaking vcruntime140.dll (64bit)

like image 60
Waldi Avatar answered Nov 02 '22 09:11

Waldi


I have also met this issue, and the root cause is that I am using upx to compress the file size. The solution is to exclude files which should not be compressed by upx:

pyinstaller --onefile --console --upx-dir=/path/to/upx --upx-exclude=vcruntime140.dll --upx-exclude=python36.dll my_script.py
like image 24
jdhao Avatar answered Nov 02 '22 10:11

jdhao