pyinstaller 打包成 exe

生成 spec 和可执行文件:

pyinstaller --onefile your_file.py

如果需要修改生成的spec文件,则后续可以这样运行:

pyinstaller -F your_file.spec


遇到2个问题:

1. 报错 找不到 mkl_pgi_thread.1.dll, 可以从python安装目录里拷到 dist 目录下和 exe放一起,更好的办法是重新安装最新版 numpy (pip install -U numpy)

2. 报错 Pyinstaller Matplotlib [Errno 2] No such file or directory: 'C:\Users\Tobi\AppData\Local\Temp\_MEI142562\matplotlib\mpl-data\matplotlibrc',我开始安装的pyinstaller是3.6, 后来换成4.5, 都不行,解决方法是重新安装了pyinstaller (pip install -U pyinstaller==4.3)

Ref:

http://events.jianshu.io/p/50329d01b6cf

https://www.cnblogs.com/the3times/p/12386007.html

https://blog.****.net/wanjuan1998/article/details/118088373