一、安装第三方插件

在线安装插件:pip install PyInstaller

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(1)

执行打包操作命令: (1)使用默认路径存放打包文件 pyinstaller -F D:\PycharmProjects\studentSys\stuSystem.py

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(2)

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(3)

optional arguments: -h, --help show this help message and exit -v, --version Show program version info and exit. --distpath DIR Where to put the bundled app (default: ./dist) --workpath WORKPATH Where to put all the temporary work files, .log, .pyz and etc. (default: ./build) -y, --noconfirm Replace output directory (default: SPECPATH\dist\SPECNAME) without asking for confirmation --upx-dir UPX_DIR Path to UPX utility (default: search the execution path) -a, --ascii Do not include unicode encoding support (default: included if available) --clean Clean PyInstaller cache and remove temporary files before building. --log-level LEVEL Amount of detail in build-time console messages. LEVEL may be one of TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL (default: INFO). What to generate: -D, --onedir Create a one-folder bundle containing an executable (default) -F, --onefile Create a one-file bundled executable. --specpath DIR Folder to store the generated spec file (default: current directory) -n NAME, --name NAME Name to assign to the bundled app and spec file (default: first script's basename)

以上表格所列出的只是PyInstaller部分常用的参数,更详细的参数可通过pyinstaller -h来查看。

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(4)


执行项目打包命令: (1)使用默认路径存放生成后的可执行文件(exe) pyinstaller -F D:\PycharmProjects\studentSys\stuSystem.py

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(5)


运行打包文件(注意:如果运行生成的exe可执行文件执行相关功能时出故障,可将可执行文件拷贝到对应的项目生成位置下,所有功能可正常运行)

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(6)

pycharm和python是怎么关联起来的(Python学习七使用PyCharm打包项目)(7)

,