Py2Exe“缺少以下模块" [英] Py2Exe "The following modules are missing"
问题描述
在使用 Py2Exe 时,我收到警告,例如
When using Py2Exe, I get a warning such as
The following modules appear to be missing
['Crypto', 'Crypto.Cipher', 'Crypto.Hash', 'Padding']
导致 EXE 错误,因为它找不到那些模块.我可以看到它们在我的站点包中,为什么它没有检测到它们?
The resulting EXE errors because it cannot find those modules. I can see they are in my site-packages, so why is it not detecting them?
注意:Crypto 和 Padding 是通过 pip/easy_install 安装的
Note: Crypto and Padding were installed through pip/easy_install
推荐答案
首先检查你的包是否是 .EGG 格式
看起来 Py2Exe 对 Python 的 .egg 包有问题.通过提取 .egg 文件(重命名为 .zip 并提取到站点包中,不包括 EGG-INFO 文件夹),Py2Exe 现在可以毫无问题地检测这些包.
It appears Py2Exe has problems with Python's .egg packages. By extracting the .egg files (rename to .zip and extract into site-packages excluding EGG-INFO folder), Py2Exe can now detect those packages without issues.
检查您的 setup.py 以确保您使用了正确的选项.窗口应用程序使用windows=",而控制台应用程序使用console="
在其他一些情况下,可以通过使用 setup(console=['main.py'])
而不是 setup(windows=['main.py'])
如果您正在生成一个窗口应用程序.
In some other cases it could be through the use of setup(console=['main.py'])
instead of setup(windows=['main.py'])
if you're producing a windowed application.
如果还是不行,你可以尝试告诉 Py2Exe 手动包含包
某些包可以通过将它们添加到 setup.py 的包选项中来进一步解析,如下所示:
Some packages can further be resolved by adding them to the package options of your setup.py like this:
setup(
windows=['main.py'],
options={
"py2exe":{
"packages": ["Crypto", "Padding"]
}
}
这篇关于Py2Exe“缺少以下模块"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!