Reputation: 588
When I use this command on my python code file in windows 10 bash shell:
pyinstaller Test.py
It produces these files (and some others):
I'm not sure if the produced file is an .exe file and will work. I cannot run it. Could you please help? Thanks.
Upvotes: 2
Views: 4856
Reputation: 5319
As I see your screenshot you have tried to run the pyinstaller
on Linux
OS because the generated *.so
files are Linux
specified shared objects. Furthermore the Test
file is a Linux
specified executable without extension.
If you want to create an EXE
file from your Python file/project, you have to run the pyintaller
on a Windows
OS. The pyinstaller
will collect all needed files Eg.: DLLs, SDKs, etc...
I have copied the below section from PyInstaller
official documentation:
PyInstaller is tested against Windows, Mac OS X, and Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a Linux app you run it in Linux, etc. PyInstaller has been used successfully with AIX, Solaris, and FreeBSD, but is not tested against them.
Some hints how you can create a working EXE
file from your Python
file/project.
Use the --onefile
or -F
flag:
"In one-file mode, there is no call to COLLECT, and the EXE instance receives all of the scripts, modules and binaries." Eg.: pyinstaller --onefile test.py
Use the --windowed
or -w
flag:
Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS X this also triggers building an OS X .app bundle. This option is ignored in *NIX systems.
Use the --clean
flag:
Clean PyInstaller
cache and remove temporary files before building.
My recommended command:
pyinstaller -Fw --clean test.py
You should run the above command on Windows
OS.
FYI:
If you have a complex Python project and you have dependencies (required files, folder structure etc...) I recommended to use a *.spec
file. You can read the detail about it on the following link: https://pythonhosted.org/PyInstaller/spec-files.html
Upvotes: 2