# 可能需要 pip install pywin32 # 必备 pip install pyinstaller # 检验安装情况 pyinstaller -v生成.py文件
在 cell 顶部添加代码
%%writefile 文件名.py终端中打包
终端 cd 进入要输出 exe 文件的目录下,执行下面的命令,我是在 Anaconda Powershell prompt 中执行的
pyinstaller -F .py文件路径
参数含义
-F 表示生成单个可执行文件
-w 表示去掉控制台窗口,这在GUI界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧!
-p 表示你自己自定义需要加载的类路径,一般情况下用不到
-i 表示可执行文件的图标
如果没有报错,则在执行目录的 dist 文件夹下查看输出的 exe 文件,其他生成的文件可以删除
- 也可以命令行指定目录地址
pyinstaller -F .py文件路径 --distpath exe存放目录
- TypeError: attrs() got an unexpected keyword argument ‘eq’
解决 pip install --upgrade attrs - AttributeError: Module ‘PyQt5’ has no attribute ‘version’
解决 pip install PyQt5 --user --use-feature=2020-resolver
相关文章:
- AttributeError: Module ‘PyQt5’ has no attribute ‘version’
- python库 Pywin32使用
- Python打包方法——Pyinstaller
- Python小技巧—jupyter notebook脚本生成exe
- Jupyter notebook交互输入方法(ipywidgets控件),包括文本框text input box,按钮button等



