Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyInstaller捆绑了太多的包_Python_Python 3.x_Pyinstaller - Fatal编程技术网

Python PyInstaller捆绑了太多的包

Python PyInstaller捆绑了太多的包,python,python-3.x,pyinstaller,Python,Python 3.x,Pyinstaller,因此,对于我的更新模块,我有一个带有TQM的progressbar系统 from tqdm import tqdm for i in tqdm(range(3)): something() 我希望没有python的朋友使用它,所以我使用PyInstaller。但是,PyInstaller会创建50mb的可执行文件。我以前使用过Py2EXE.net,它提供了~6-7MB.exe文件。从输出日志中,我猜它已经决定复制我的所有站点包,我有大约200个包 如何阻止PyInsta

因此,对于我的更新模块,我有一个带有TQM的progressbar系统

from tqdm import tqdm
    for i in tqdm(range(3)):
        something()
我希望没有python的朋友使用它,所以我使用PyInstaller。但是,PyInstaller会创建50mb的可执行文件。我以前使用过Py2EXE.net,它提供了~6-7MB.exe文件。从输出日志中,我猜它已经决定复制我的所有站点包,我有大约200个包

如何阻止PyInstaller复制我的所有包,而只复制TQM

PyInstaller日志
(日志输出不适合这里。)

我刚刚遇到了这个特定的问题。TQM库使用其他大型模块。如果您阅读详细信息,您将看到有多少模块正在加载。 有效地使您的exe为50MB+~

具有很轻依赖性的替代方案。如果您的脚本没有导入其他大型模块,您的exe大约为5MB。

我通过确保在虚拟环境中运行包含所有必需库的
pyinstaller
解决了这个问题

创建并激活venv:

python3 -m venv venv
source venv/bin/activate
在venv内安装
pyinstaller
和所需的库:

pip install pyinstaller
然后捆绑:

pyinstaller myfile.py --onefile

您能否提供您使用的确切的
pyinstaller
调用?在安装了
tqdm
的MacOS 10.13.3中,我通过运行以下命令获得5MB文件:
pyinstaller--clean--onefile myscript.py
tqdm
有一些令人惊讶的
import
语句,这可能是您看到的额外模块的原因。@MaxShenfield我使用的是
pyinstaller myfile.py--onefile