pyinstaller package exe file under windows

pyinstaller package exe file

  • pyinstaller install
pip install pyinstaller
  • package command
pyinstaller -F pythonfile.py -w

-wThe 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 .builddistdist

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.

Guess you like

Origin blog.csdn.net/chinesesexyman/article/details/106687290