更新时间:2023-12-01 22:49:40
PyInstaller从conda软件包创建大型可执行文件,从pip软件包创建小型可执行文件.通过以下简单的python代码:
PyInstaller create the big executable from the conda packages and the small executable from the pip packages. From this simple python code:
from pandas import DataFrame as df
print('h')
我获得了conda软件包的203MB可执行文件和pip软件包的30MB可执行文件.但是conda是纯virtualenv的不错替代.我可以使用conda和Jupyter进行开发,创建一些mycode.py(我可以在myfolder中将pypy文件下载为pypy文件).但是接下来是我的最终解决方案: 如果没有安装,请安装 Miniconda ,然后从Windows开始"菜单中打开Anaconda提示符;
I obtain the 203MB executable by the conda packages and the 30MB executable by the pip packages. But conda is the nice replacement of the pure virtualenv. I can develop with conda and Jupyter, create some mycode.py (I can download jupyter notebook as py-file in myfolder). But my final solution is next: If you do not have it, install Miniconda and from the Windows Start Menu open Anaconda Prompt;
cd myfolder
conda create -n exe python=3
activate exe
pip install pandas pyinstaller pypiwin32
echo hiddenimports = ['pandas._libs.tslibs.timedeltas'] > %CONDA_PREFIX%\Lib\site-packages\PyInstaller\hooks\hook-pandas.py
pyinstaller -F mycode.py
在我创建新环境'exe'的地方,pypiwin32需要pyinstaller,但不会自动安装,hook-pandas.py需要与pandas一起编译. 另外,导入子模块也无法帮助我优化可执行文件的大小. 所以我不需要这个东西:
Where I create new environment 'exe', pypiwin32 need for pyinstaller but is not installed automaticaly, hook-pandas.py need for compile with pandas. Also, import submodules do not help me optimize the size of the executable file. So I do not need this thing:
from pandas import DataFrame as df
但是我只能使用通常的代码:
but I can just use the usual code:
import pandas as pd
此外,在路径中使用国家字母可能会导致一些错误,因此使用开发工具的英语用户帐户很好.
Also, some errors are possible along using the national letters in paths, so it is nice the english user account for development tools.