Reputation: 53
I beg your pardon in advance, my English is bad. I use Google Translate.
Simple code — print("Hello!")
Here's what's in the terminal:
PS C:\OOTDDir\PythonDev\pizza> pyinstaller -F hello.py
109 INFO: PyInstaller: 4.5.1
109 INFO: Python: 3.9.6
109 INFO: Platform: Windows-10-10.0.19042-SP0
109 INFO: wrote C:\OOTDDir\PythonDev\pizza\hello.spec
109 INFO: UPX is not available.
109 INFO: Extending PYTHONPATH with paths
['C:\\OOTDDir\\PythonDev\\pizza', 'C:\\OOTDDir\\PythonDev\\pizza']
464 INFO: checking Analysis
465 INFO: Building Analysis because Analysis-00.toc is non existent
465 INFO: Initializing module dependency graph...
467 INFO: Caching module graph hooks...
486 INFO: Analyzing base_library.zip ...
3150 INFO: Processing pre-find module path hook distutils from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
3150 INFO: distutils: retargeting to non-venv dir 'c:\\ootddir\\python\\lib'
6278 INFO: Caching module dependency graph...
6482 INFO: running Analysis Analysis-00.toc
6484 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\ootddir\python\python.exe
6546 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\ootddir\python\python39.dll
6718 INFO: Analyzing C:\OOTDDir\PythonDev\pizza\hello.py
6718 INFO: Processing module hooks...
6718 INFO: Loading module hook 'hook-difflib.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6718 INFO: Loading module hook 'hook-distutils.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6718 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6734 INFO: Loading module hook 'hook-encodings.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6812 INFO: Loading module hook 'hook-heapq.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6812 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6953 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6953 INFO: Loading module hook 'hook-pickle.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6953 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6953 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
6953 INFO: Loading module hook 'hook-xml.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7015 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7125 INFO: checking Tree
7125 INFO: Building Tree because Tree-00.toc is non existent
7125 INFO: Building Tree Tree-00.toc
7250 INFO: checking Tree
7250 INFO: Building Tree because Tree-01.toc is non existent
7250 INFO: Building Tree Tree-01.toc
7328 INFO: checking Tree
7328 INFO: Building Tree because Tree-02.toc is non existent
7328 INFO: Building Tree Tree-02.toc
7356 INFO: Looking for ctypes DLLs
7372 INFO: Analyzing run-time hooks ...
7376 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
7381 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
7384 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
7392 INFO: Looking for dynamic libraries
7536 INFO: Looking for eggs
7536 INFO: Using Python library c:\ootddir\python\python39.dll
7536 INFO: Found binding redirects:
[]
7536 INFO: Warnings written to C:\OOTDDir\PythonDev\pizza\build\hello\warn-hello.txt
7583 INFO: Graph cross-reference written to C:\OOTDDir\PythonDev\pizza\build\hello\xref-hello.html
7599 INFO: checking PYZ
7599 INFO: Building PYZ because PYZ-00.toc is non existent
7599 INFO: Building PYZ (ZlibArchive) C:\OOTDDir\PythonDev\pizza\build\hello\PYZ-00.pyz
8148 INFO: Building PYZ (ZlibArchive) C:\OOTDDir\PythonDev\pizza\build\hello\PYZ-00.pyz completed successfully.
8164 INFO: checking PKG
8164 INFO: Building PKG because PKG-00.toc is non existent
8164 INFO: Building PKG (CArchive) PKG-00.pkg
10044 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
10044 INFO: Bootloader c:\ootddir\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
10044 INFO: checking EXE
10060 INFO: Building EXE because EXE-00.toc is non existent
10060 INFO: Building EXE from EXE-00.toc
10062 INFO: Copying icons from ['c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
10062 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
10062 INFO: Writing RT_ICON 1 resource with 3752 bytes
10062 INFO: Writing RT_ICON 2 resource with 2216 bytes
10062 INFO: Writing RT_ICON 3 resource with 1384 bytes
10062 INFO: Writing RT_ICON 4 resource with 37019 bytes
10062 INFO: Writing RT_ICON 5 resource with 9640 bytes
10062 INFO: Writing RT_ICON 6 resource with 4264 bytes
10062 INFO: Writing RT_ICON 7 resource with 1128 bytes
10078 INFO: Updating manifest in C:\OOTDDir\PythonDev\pizza\build\hello\run.exe.mx2u8v5f
10078 INFO: Updating resource type 24 name 1 language 0
10078 INFO: Appending archive to EXE C:\OOTDDir\PythonDev\pizza\dist\hello.exe
11616 INFO: Building EXE from EXE-00.toc completed successfully.
Removing the "F" flag does not solve the problem.
PyInstaller creates a file, but it closes immediately upon clicking. In a situation where I try to run my test game code, with the window flag -w, I see an error: Error
And in the terminal it is:
PS C:\OOTDDir\PythonDev\alien_invasion> pyinstaller -F alien_invasion.py
54 INFO: PyInstaller: 4.5.1
54 INFO: Python: 3.9.6
70 INFO: Platform: Windows-10-10.0.19042-SP0
70 INFO: wrote C:\OOTDDir\PythonDev\alien_invasion\alien_invasion.spec
70 INFO: UPX is not available.
70 INFO: Extending PYTHONPATH with paths
['C:\\OOTDDir\\PythonDev\\alien_invasion',
'C:\\OOTDDir\\PythonDev\\alien_invasion']
305 INFO: checking Analysis
305 INFO: Building Analysis because Analysis-00.toc is non existent
305 INFO: Initializing module dependency graph...
321 INFO: Caching module graph hooks...
336 INFO: Analyzing base_library.zip ...
2691 INFO: Processing pre-find module path hook distutils from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2691 INFO: distutils: retargeting to non-venv dir 'c:\\ootddir\\python\\lib'
5835 INFO: Caching module dependency graph...
6007 INFO: running Analysis Analysis-00.toc
6022 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\ootddir\python\python.exe
6100 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\ootddir\python\python39.dll
6288 INFO: Analyzing C:\OOTDDir\PythonDev\alien_invasion\alien_invasion.py
6535 INFO: Processing pre-find module path hook site from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
6551 INFO: site: retargeting to fake-dir 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\fake-modules'
7554 INFO: Processing module hooks...
7554 INFO: Loading module hook 'hook-pygame.py' from 'c:\\ootddir\\python\\lib\\site-packages\\pygame\\__pyinstaller'...
pygame 2.0.1 (SDL 2.0.14, Python 3.9.6)
Hello from the pygame community. https://www.pygame.org/contribute.html
7601 INFO: Loading module hook 'hook-difflib.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7617 INFO: Loading module hook 'hook-distutils.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7617 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7617 INFO: Loading module hook 'hook-encodings.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7695 INFO: Loading module hook 'hook-heapq.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7695 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7868 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7884 INFO: Loading module hook 'hook-pickle.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
7884 INFO: Loading module hook 'hook-pkg_resources.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8167 INFO: Processing pre-safe import module hook win32com from 'c:\\ootddir\\python\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
8443 WARNING: Hidden import "pkg_resources.py2_warn" not found!
8443 WARNING: Hidden import "pkg_resources.markers" not found!
8443 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8443 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8583 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8583 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8583 INFO: Loading module hook 'hook-xml.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8583 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks'...
8694 INFO: checking Tree
8694 INFO: Building Tree because Tree-00.toc is non existent
8694 INFO: Building Tree Tree-00.toc
8757 INFO: checking Tree
8757 INFO: Building Tree because Tree-01.toc is non existent
8757 INFO: Building Tree Tree-01.toc
8820 INFO: checking Tree
8820 INFO: Building Tree because Tree-02.toc is non existent
8820 INFO: Building Tree Tree-02.toc
8851 INFO: Looking for ctypes DLLs
8882 INFO: Analyzing run-time hooks ...
8882 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
8898 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
8898 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
8898 INFO: Including run-time hook 'c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
8914 INFO: Looking for dynamic libraries
9336 INFO: Looking for eggs
9336 INFO: Using Python library c:\ootddir\python\python39.dll
9336 INFO: Found binding redirects:
[]
9336 INFO: Warnings written to C:\OOTDDir\PythonDev\alien_invasion\build\alien_invasion\warn-alien_invasion.txt
9398 INFO: Graph cross-reference written to C:\OOTDDir\PythonDev\alien_invasion\build\alien_invasion\xref-alien_invasion.html
9414 INFO: checking PYZ
9414 INFO: Building PYZ because PYZ-00.toc is non existent
9414 INFO: Building PYZ (ZlibArchive) C:\OOTDDir\PythonDev\alien_invasion\build\alien_invasion\PYZ-00.pyz
10090 INFO: Building PYZ (ZlibArchive) C:\OOTDDir\PythonDev\alien_invasion\build\alien_invasion\PYZ-00.pyz completed successfully.
10105 INFO: checking PKG
10105 INFO: Building PKG because PKG-00.toc is non existent
10105 INFO: Building PKG (CArchive) PKG-00.pkg
12901 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
12901 INFO: Bootloader c:\ootddir\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
12901 INFO: checking EXE
12901 INFO: Building EXE because EXE-00.toc is non existent
12901 INFO: Building EXE from EXE-00.toc
12901 INFO: Copying icons from ['c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
12901 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
12901 INFO: Writing RT_ICON 1 resource with 3752 bytes
12901 INFO: Writing RT_ICON 2 resource with 2216 bytes
12901 INFO: Writing RT_ICON 3 resource with 1384 bytes
12901 INFO: Writing RT_ICON 4 resource with 37019 bytes
12901 INFO: Writing RT_ICON 5 resource with 9640 bytes
12901 INFO: Writing RT_ICON 6 resource with 4264 bytes
12901 INFO: Writing RT_ICON 7 resource with 1128 bytes
12901 INFO: Updating manifest in C:\OOTDDir\PythonDev\alien_invasion\build\alien_invasion\run.exe.m_3ze9i1
12901 INFO: Updating resource type 24 name 1 language 0
12916 INFO: Appending archive to EXE C:\OOTDDir\PythonDev\alien_invasion\dist\alien_invasion.exe
15159 INFO: Building EXE from EXE-00.toc completed successfully.
PS C:\OOTDDir\PythonDev\alien_invasion> pyinstaller -F -w alien_invasion.py
63 INFO: PyInstaller: 4.5.1
63 INFO: Python: 3.9.6
79 INFO: Platform: Windows-10-10.0.19042-SP0
79 INFO: wrote C:\OOTDDir\PythonDev\alien_invasion\alien_invasion.spec
79 INFO: UPX is not available.
79 INFO: Extending PYTHONPATH with paths
['C:\\OOTDDir\\PythonDev\\alien_invasion',
'C:\\OOTDDir\\PythonDev\\alien_invasion']
318 INFO: checking Analysis
333 INFO: checking PYZ
349 INFO: checking PKG
366 INFO: Bootloader c:\ootddir\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
366 INFO: checking EXE
366 INFO: Building because console changed
366 INFO: Building EXE from EXE-00.toc
407 INFO: Copying icons from ['c:\\ootddir\\python\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
407 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
407 INFO: Writing RT_ICON 1 resource with 3752 bytes
407 INFO: Writing RT_ICON 2 resource with 2216 bytes
407 INFO: Writing RT_ICON 3 resource with 1384 bytes
407 INFO: Writing RT_ICON 4 resource with 38188 bytes
407 INFO: Writing RT_ICON 5 resource with 9640 bytes
407 INFO: Writing RT_ICON 6 resource with 4264 bytes
407 INFO: Writing RT_ICON 7 resource with 1128 bytes
407 INFO: Updating manifest in C:\OOTDDir\PythonDev\alien_invasion\build\alien_invasion\runw.exe.2gd3qgqs
407 INFO: Updating resource type 24 name 1 language 0
407 INFO: Appending archive to EXE C:\OOTDDir\PythonDev\alien_invasion\dist\alien_invasion.exe
2778 INFO: Building EXE from EXE-00.toc completed successfully.
I went through a large number of sites, but did not find a solution. I have been studying Python for about the second month, and for the first time I encountered such an incomprehensible problem. Frankly, I'm desperate. I almost finished analyzing the basic functions of PyGame and thought to start writing my own game, but I spent a lot of hours on this problem and it completely unsettled me.
The only hope is for you. Sorry for the verbosity.
Eventually:
It was enough to transfer the folder with the resources to the folder with the .exe file (in my case, this is the "images" folder with ".bmp" files).
In the case of a console application, input
solves the same problem, and if you enclose it in a while
loop, there will be no problem either.
Upvotes: 0
Views: 3448
Reputation: 1054
If the program closes right after it gets opened, it means that either you have an error in your code, or that everything just worked fine and the code finish executing.
If you run your code as a .py
file and everything worked, it means that the problem is that the code just finishes executing so it closes automatically. In this scenario, you could just add a simple
while True:
pass
Infinite loop, that does nothing, at the end of your script. Just now that the screen will freeze once he gets to this code, but won't close right after opening.
Upvotes: 1