The python program is packaged into an exe -- pyinstaller

  1. Install the pyinstaller package
    pip install pyinstaller
  2. Use pyinstaller command
    common parameters https://www.jb51.net/article/206825.htm
    eg:
    pyinstaller -w --distpath ..\DirectRun -y -F -n 手势操作.exe --add-data="E:\anaconda\Lib\site-packages\mediapipe\modules;mediapipe\modules" -i ..\minicar.ico hands_controller.py
    

​ -w Do not display the command line window (if not added, the command line window will be displayed by default)
–distpath Where to place the generated file (if not added, it will be generated in the dist folder of the current directory)
​ -y Overwrite (if not added, it will ask whether by default Overwrite)
​ -F Generate an exe file (if not added, a directory will be generated, and various third-party dependencies, resources and exe will be stored in this directory at the same time)
​ -n The name of the generated exe file (if not added, the name of the default .py file)
​ -i Execute the icon
–add-data to add third-party library files. Sometimes you need to use this command if you find that files are missing at runtime after packaging. I used mediapipe in the project, and the result shows that it is
insert image description here
repaired after adding –add-data, the source address is before the semicolon, and the destination address is after the semicolon. (Bug fix reference article: https://blog.csdn.net/xujianjun229/article/details/120049583?spm=1001.2014.3001.5506)

Guess you like

Origin blog.csdn.net/qq_42283621/article/details/124205494