我一直在尝试在 Windows 10 中使用 pyinstaller 构建 .exe 文件.它有效,但 exe 文件的大小约为 212 MB,即使使用 venv 也是如此(如 这里).我想这可能是因为我正在使用 anaconda 的 python!
I have been trying to build .exe file using pyinstaller in windows 10. It worked, but the size of the exe file is ~212 MB, even by using a venv (as in here). I thought it might be because I am using python by anaconda!
然后我安装了一个单独的 Python 版本,所以不要使用 anaconda!但它不起作用(仍然是大文件).
Then I installed a separate version of Python so not to use anaconda! But it did not work (still large file).
然后我卸载了 anaconda 进行测试.Pyinstaller 仍在尝试访问C:Program Filesanaconda3python.exe"中的 Python(此错误:C:Program Filesanaconda3python.exe"中没有 Python).但是我已经删除了所有到 anaconda 的路径.可能它一直试图到达 anaconda,这就是为什么我没有成功构建一个小尺寸的 .exe 文件.
Then I uninstalled anaconda to test it. Pyinstaller is still trying to access Python in 'C:Program Filesanaconda3python.exe' (this error: No Python at 'C:Program Filesanaconda3python.exe'). However I have removed all path to anaconda. Probably it has always tried to reach anaconda, and this is why I haven't been successful to build a small size .exe file.
如何清楚地指明 pyinstaller 和 python 的路径?
How can I clearly indicate paths for pyinstaller and python?
终于,经过大量研究,可以解决我的问题:
Finally, after a lot of researching, could solve my problem:
注意:您可以在其中构建 virtualenv 并执行 pyinstaller.
Note: You can build virtualenv and do pyinstaller in them.
我之前使用 anaconda 的尝试导致文件大小为 212 MB.这个过程生成了一个大小为 27 MB 的 .exe 文件(仅导入 pandas 模块).
My previous tries which used anaconda resulted in file of 212 MB in size. This process generated a .exe file of size 27 MB (Importing only pandas module).
这篇关于如何使pyinstaller不使用anaconda并构建一个小型exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!