安装:
pip install pyinstaller
重点:可单独建立虚拟环境打包,不然可能文件会很大
eg:
pyinstaller -w -F --icon=icon.ico video_collect.py
Error1
No such file or directory: 'C:\Users\yuyang\AppData\Local\Temp\_MExx\xxxx\xx错误
命名一个hook-xxxx的py文件,xxxx代表包名,本例中为uiautomator2
在py中写入:
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files(package="xxxx", include_py_files=True) #include_py_files=True,代表要copy的文件包含脚本文件,此处False报错
保存将此py文件放入Pyinstaller下的hook的文件夹中,重新打包spec。
pyinstaller -F absoultpath.py
Error2
打开界面后显示No module requests;
解决:
1、pip install requests
2、卸载pyinstaller,重新安装
3、重新开启命令行