Reputation: 95
So far I have used cx_freeze to convert .py file to .exe file, but I get many files. Is there a way to get it all into one executable?
I have seen that PyInstallerGUI is able to that, but it is for Python 2.7. Can it be done with Python 3.4 as well?
Upvotes: 7
Views: 26773
Reputation: 31
I found this in the PyInstaller documentation:
pyinstaller --onefile your-python-file.py
To find more: PyInstaller documentation
Upvotes: 3
Reputation: 1330
PyInstaller works up to Python 3.5. Once you've installed it (type in your terminal pip install pyinstaller
), you can do in your terminal:
pyinstaller --onefile script.py
where script.py
is the name of script you want to compile into .exe
With the --onefile
option it will create only one .exe file.
Upvotes: 15
Reputation: 7944
I haven't tried it but, PyInstaller says here it can do that and it supports Python 2.7 and Python 3.3+.
Quoting from the linked page:
PyInstaller can bundle your script and all its dependencies into a single executable named myscript (
myscript.exe
in Windows).The advantage is that your users get something they understand, a single executable to launch. A disadvantage is that any related files such as a README must be distributed separately. Also, the single executable is a little slower to start up than the one-folder bundle.
Before you attempt to bundle to one file, make sure your app works correctly when bundled to one folder. It is is much easier to diagnose problems in one-folder mode.
Upvotes: 5