Table of contents
pyinstaller package exe file
- pyinstaller install
pip install pyinstaller
- package command
pyinstaller -F pythonfile.py -w
-w
The parameter indicates that the command window will not pop up when the exe is running. Two folders are generated in the current directory, and the exe file with the same name as the py file is under the
folder .build
dist
dist
some pits
Get the current file path of exe
import os
import sys
print(os.path.dirname(os.path.realpath(sys.argv[0])))
__file__
method cannot be used, usesys.argv[0]
Undefined timing of destructor call
When the exe program is closed, the class method __del__
may not be executed in time, it is best not to write important logic __del__
into it. In fact, any call in a python program __del__
does not necessarily execute immediately, because python uses automatic reference counting (Automatic Reference Counting) for garbage collection.