<>Python Generate executable file exe

<> one , install pyinstaller

pip install pyinstaller

<> two , use pyinstaller command

<> Use examples

* Relative path
In the program directory , Run command pyinstaller myscript.py
You can generate two folders in the current directory dist and build,exe File in dist Folder .
* Absolute path
In the program directory , Run command pyinstaller C:\myscript.py
Is generated in the directory where the command is currently executed dist and build folder
<> Common command parameters

* -F Specifies that only one is generated after packaging exe Format file
as :pyinstaller -F T1.py
be dist There is only one file exe Format file T1
* -i Change the generation process icon Icon
pyinstaller -F -i ./my.ico T1.py
* -n NAME,–name=NAME Set the name of the generated file (mypy)
pyinstaller -F -n mypy -i ./my.ico T1.py
<> three , When packing multiple files

* Existing package , Master file :pyinstaller -F main.py -p ./tools
* There is no bag , however py Time :pyinstaller -F main.py -p getexcel.py
<> supplement

* -c, –console, –nowindowed Using the console , No interface ( default )
* -w, –windowed, –noconsole Using Windows , No console
<> common problem

* routing problem : use pyinstaller When packing , If used rootPath =
os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
Then it will exe The path in the packing process is packed in , have access to os.path.dirname(os.path.realpath(sys.argv[0]))
Get the current run py, current path

Technology
©2020 ioDraw All rights reserved
Swing actual combat Understanding closure about vue in el-date-picker type=daterange The problem of date not echoing Ubuntu 18.04 swap Partition expansion Snake code --c Language Edition visual c++6.0 open 【Golang Basic series 10 】Go language On conditional sentences ifString class —— summary ,String The nature of , Memory resolution , Commonly used APIAdobe Illustrator Publish native support Apple Silicon Test version of the software study java My first class antd table sort