How to make .exe file - jdrp - Jun-07-2018
Is there any way I can make a .exe file from a .py script so I can run it on other computers without having to install python?
I'm using Python 3.6 and all the options I've tried, such as cxfreezer and pyinstaller don't work. Any ideas?
Btw, if anybody wants the files I would share them, but as the program uses Pygame and has some assets, I'd have to upload it to Google Drive. But I'll do it if anyone can make a .exe out of them.
RE: How to make .exe file - j.crater - Jun-08-2018
Post the steps of your attempts at getting an exe and errors you get. I have had some success with PyInstaller, although not used with PyGame. But someone on the forum may be able to help you anyway.
RE: How to make .exe file - jdrp - Jun-08-2018
I' ve tried so many things that I don't really know what was what. I just need ideas that actually work with 3.6
RE: How to make .exe file - ljmetzger - Jun-08-2018
Quote:I'm using Python 3.6 and all the options I've tried, such as cxfreezer and pyinstaller don't work.
They do not work at all, or they do not work with your code? If it does not work with your code, try uploading the simplest extract of your code that works in Python, and does not work with PyInstaller.
If it does not work at all, try creating a .exe file from a simple 'Hello World' Python file.
For example, to use PyInstaller to create an executable file only:
PyInstaller -F abcd.py (creates 'abcd.exe' in 'dist' subfolder).
Without the -F option, PyInstaller creates subfolder 'abcd' in 'dist' subfolder and a zip file of the 'abcd' subfolder must be distributed.
Lewis
RE: How to make .exe file - jdrp - Jun-09-2018
I tried a hello world script and it did work, even though it threw a lot of warnings. Here's my whole code if anyone wants to check it out. It does use Pygame, so it won't work unless you have it installed. Could that be the reason it doesn't work? Or is there a way to kind of include pygame in the .exe file?
RE: How to make .exe file - ljmetzger - Jun-09-2018
Using PyInstaller 3.3.1, I could not duplicate your warning messages on Windows 10 using Python 3.6.5.
I did everything interactively from cmd.exe. To isolate the problem, I worked from the main Python folder c:\Python36. I deleted subfolders 'dist' and 'build', both of which are used by PyInstaller. I removed the PATH environment variable and ran PyInstaller from the scripts subfolder explicitly.
c:\Python>scripts\pyinstaller -F helloworld.py
I got the following warning messages and helloworld.exe was created successfully in the 'dist' subfolder
Output: 662 INFO: PyInstaller: 3.3.1
662 INFO: Python: 3.6.5
663 INFO: Platform: Windows-10-10.0.17134-SP0
664 INFO: wrote c:\Python\helloworld.spec
665 INFO: UPX is not available.
669 INFO: Extending PYTHONPATH with paths
['c:\\Python', 'c:\\Python']
669 INFO: checking Analysis
669 INFO: Building Analysis because out00-Analysis.toc is non existent
670 INFO: Initializing module dependency graph...
681 INFO: Initializing module graph hooks...
685 INFO: Analyzing base_library.zip ...
8025 INFO: running Analysis out00-Analysis.toc
8031 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python\python.exe
8066 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\python\python.exe
8100 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\python.exe
8119 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\python.exe
8135 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\python.exe
8149 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\python.exe
8167 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8185 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8199 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8214 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8228 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8369 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\python\python36.dll
8388 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\python36.dll
8402 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\python36.dll
8417 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\python\python36.dll
8438 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python\python36.dll
8453 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\python36.dll
8470 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\python36.dll
8487 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\python36.dll
8503 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\python36.dll
8519 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\python\python36.dll
8534 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\python36.dll
8548 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\python36.dll
8556 INFO: Caching module hooks...
8565 INFO: Analyzing c:\Python\helloworld.py
8570 INFO: Loading module hooks...
8570 INFO: Loading module hook "hook-encodings.py"...
8823 INFO: Loading module hook "hook-pydoc.py"...
8823 INFO: Loading module hook "hook-xml.py"...
9209 INFO: Looking for ctypes DLLs
9210 INFO: Analyzing run-time hooks ...
9217 INFO: Looking for dynamic libraries
9248 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9265 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9286 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9302 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9318 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9333 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9349 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9364 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9380 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9407 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
9433 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\unicodedata.pyd
9449 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\unicodedata.pyd
9465 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\unicodedata.pyd
9490 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
9505 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
9523 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
9542 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
9560 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
9593 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9609 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9625 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9641 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9658 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9674 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9690 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9706 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9729 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
9757 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
9773 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
9790 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
9806 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
9822 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
9843 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_lzma.pyd
9859 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\_lzma.pyd
9887 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_socket.pyd
9916 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\select.pyd
9920 INFO: Looking for eggs
9920 INFO: Using Python library c:\python\python36.dll
9920 INFO: Found binding redirects:
[]
9927 INFO: Warnings written to c:\Python\build\helloworld\warnhelloworld.txt
9983 INFO: Graph cross-reference written to c:\Python\build\helloworld\xref-helloworld.html
9998 INFO: checking PYZ
9998 INFO: Building PYZ because out00-PYZ.toc is non existent
9998 INFO: Building PYZ (ZlibArchive) c:\Python\build\helloworld\out00-PYZ.pyz
10573 INFO: Building PYZ (ZlibArchive) c:\Python\build\helloworld\out00-PYZ.pyz completed successfully.
10582 INFO: checking PKG
10583 INFO: Building PKG because out00-PKG.toc is non existent
10583 INFO: Building PKG (CArchive) out00-PKG.pkg
11811 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
11815 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
11815 INFO: checking EXE
11815 INFO: Building EXE because out00-EXE.toc is non existent
11816 INFO: Building EXE from out00-EXE.toc
11816 INFO: Appending archive to EXE c:\Python\dist\helloworld.exe
11840 INFO: Building EXE from out00-EXE.toc completed successfully.
c:\Python>dist\helloworld.exe
Output: Hello World!
I ran PyInstaller again after deleting the 'dist' subfolder (contained helloworld.exe) only.
c:\Python>scripts\pyinstaller -F helloworld.py
Output: 632 INFO: PyInstaller: 3.3.1
633 INFO: Python: 3.6.5
633 INFO: Platform: Windows-10-10.0.17134-SP0
635 INFO: wrote c:\Python\helloworld.spec
636 INFO: UPX is not available.
639 INFO: Extending PYTHONPATH with paths
['c:\\Python', 'c:\\Python']
640 INFO: checking Analysis
704 INFO: checking PYZ
747 INFO: checking PKG
754 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
754 INFO: checking EXE
754 INFO: Rebuilding out00-EXE.toc because helloworld.exe missing
755 INFO: Building EXE from out00-EXE.toc
755 INFO: Appending archive to EXE c:\Python\dist\helloworld.exe
779 INFO: Building EXE from out00-EXE.toc completed successfully.
c:\Python>dist\helloworld.exe
Output: Hello World!
After installing pygame with pip, I was able to create snake.exe using Using PyInstaller 3.3.1 on Windows 10 using Python 3.6.5.
pyinstaller -F snake.py
Output edited due to the large number of warnings:
Output: 677 INFO: PyInstaller: 3.3.1
677 INFO: Python: 3.6.5
678 INFO: Platform: Windows-10-10.0.17134-SP0
682 INFO: wrote C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\snake.spec
684 INFO: UPX is not available.
689 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Owner\\Documents\\Lew\\WindowsBatchFiles\\Python Lewis',
'C:\\Users\\Owner\\Documents\\Lew\\WindowsBatchFiles\\Python Lewis']
689 INFO: checking Analysis
690 INFO: Building Analysis because out00-Analysis.toc is non existent
690 INFO: Initializing module dependency graph...
703 INFO: Initializing module graph hooks...
708 INFO: Analyzing base_library.zip ...
6240 INFO: running Analysis out00-Analysis.toc
6245 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python\python.exe
6329 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\python.exe
6395 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\python.exe
6461 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\python.exe
...
7728 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\python36.dll
7791 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python\python36.dll
7857 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\python\python36.dll
7863 INFO: Caching module hooks...
7871 INFO: Analyzing C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\snake.py
9846 INFO: Processing pre-find module path hook distutils
15701 INFO: Processing pre-find module path hook site
15709 INFO: site: retargeting to fake-dir 'c:\\python\\lib\\site-packages\\PyInstaller\\fake-modules'
25601 INFO: Loading module hooks...
25601 INFO: Loading module hook "hook-distutils.py"...
25611 INFO: Loading module hook "hook-encodings.py"...
25883 INFO: Loading module hook "hook-lib2to3.py"...
25910 INFO: Loading module hook "hook-numpy.core.py"...
26392 INFO: Loading module hook "hook-pkg_resources.py"...
27864 INFO: Processing pre-safe import module hook win32com
28265 INFO: Loading module hook "hook-pydoc.py"...
28267 INFO: Loading module hook "hook-pygame.py"...
28270 WARNING: Hidden import "pygame._view" not found!
28271 INFO: Loading module hook "hook-pythoncom.py"...
29047 INFO: Loading module hook "hook-pywintypes.py"...
29790 INFO: Loading module hook "hook-setuptools.py"...
29841 INFO: Loading module hook "hook-sysconfig.py"...
29857 INFO: Loading module hook "hook-win32com.py"...
31116 INFO: Loading module hook "hook-xml.dom.domreg.py"...
31119 INFO: Loading module hook "hook-xml.py"...
31225 INFO: Looking for ctypes DLLs
31340 INFO: Analyzing run-time hooks ...
31356 INFO: Including run-time hook 'pyi_rth_pkgres.py'
31376 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
31398 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
31460 INFO: Looking for dynamic libraries
31604 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\pywin32_system32\pythoncom36.dll
31679 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\pywin32_system32\pythoncom36.dll
...
45523 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\lib\site-packages\Pythonwin\mfc140u.dll
45591 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\lib\site-packages\Pythonwin\mfc140u.dll
55805 INFO: Looking for eggs
55805 INFO: Using Python library c:\python\python36.dll
55806 INFO: Found binding redirects:
[]
55818 INFO: Warnings written to C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\build\snake\warnsnake.txt
55960 INFO: Graph cross-reference written to C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\build\snake\xref-snake.html
56002 INFO: checking PYZ
56002 INFO: Building PYZ because out00-PYZ.toc is non existent
56003 INFO: Building PYZ (ZlibArchive) C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\build\snake\out00-PYZ.pyz
57397 INFO: Building PYZ (ZlibArchive) C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\build\snake\out00-PYZ.pyz completed successfully.
57419 INFO: checking PKG
57419 INFO: Building PKG because out00-PKG.toc is non existent
57420 INFO: Building PKG (CArchive) out00-PKG.pkg
57460 INFO: Updating manifest in C:\Users\Owner\AppData\Roaming\pyinstaller\bincache00_py36_32bit\_decimal.pyd
57472 INFO: Updating resource type 24 name 2 language 1033
57490 INFO: Updating manifest in C:\Users\Owner\AppData\Roaming\pyinstaller\bincache00_py36_32bit\_multiprocessing.pyd
...
58308 INFO: Updating manifest in C:\Users\Owner\AppData\Roaming\pyinstaller\bincache00_py36_32bit\pygame.base.pyd
58309 INFO: Updating resource type 24 name 2 language 1033
65954 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
65966 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
65966 INFO: checking EXE
65967 INFO: Building EXE because out00-EXE.toc is non existent
65967 INFO: Building EXE from out00-EXE.toc
65969 INFO: Appending archive to EXE C:\Users\Owner\Documents\Lew\WindowsBatchFiles\Python Lewis\dist\snake.exe
66058 INFO: Building EXE from out00-EXE.toc completed successfully.
snake.exe ran until I got an expected Traceback error because I did not have coin.png installed.
Number of players (1/2)? 1
Traceback (most recent call last):
File "snake.py", line 83, in <module>
File "snake.py", line 73, in __init__
pygame.error: Couldn't open coin.png
[33828] Failed to execute script snake
snake.exe is too large to upload as an attachment. You should be able to download it from my One Drive Account: https://1drv.ms/u/s!Ai5d6PFH3s1piz103WGl8zeFcv9t
Lewis
RE: How to make .exe file - Blue Dog - Jun-10-2018
try this https://pytoexe.com/
RE: How to make .exe file - ljmetzger - Jun-10-2018
My anti-virus program will not let me access the URL you posted.
See the following for a simple comparison of various freeze progams: http://docs.python-guide.org/en/latest/shipping/freezing/
I chose to use pyInstaller because it was the simplest to use. I don't have a need for creating .exe files, I was just interested in the tools available.
Lewis
|