使用 py2exe 构建控制台可执行文件,收到 suds 导入错误
尝试使用 py2exe 构建 .exe: python setup.py py2exe
,收到错误:
ImportError: No module named suds
我做了一些研究,表明该模块必须专门包含在 setup.py 中。这是我的 setup.py:
from distutils.core import setup
import py2exe
setup(console = [{'script':'report.py'}],
options = {
'py2exe': {
'bundle_files' : 1,
'includes' : ['suds']
}
})
我尝试包含包名称 suds.client
、suds.transport.https
,但错误仍然存在。 py2exe 似乎在此处找到了几个特定于模块的要求,但我没有看到任何特定于泡沫的要求文档。
在此处找到了有关 py2exe 如何查找必要模块的一些信息。输出
C:\Python27>python -m py2exe.mf -d /path/to/report.py
path:
''
'C:\\Python27\\lib\\site-packages\\pyyaml-3.10-py2.7-win32.egg'
'C:\\Python27\\lib\\site-packages\\progressbar-2.3-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\sqlalchemy-0.7.2-py2.7-win32.egg'
'C:\\Python27\\lib\\site-packages\\soappy-0.12.5-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\wstools-0.3-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\fpconst-0.7.2-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\python_ntlm-1.0.1-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\django-1.3-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\pyodbc-2.1.9-py2.7-win32.egg'
'C:\\Python27\\lib\\site-packages\\suds-0.4-py2.7.egg'
'C:\\Windows\\system32\\python27.zip'
'C:\\Python27\\DLLs'
'C:\\Python27\\lib'
'C:\\Python27\\lib\\plat-win'
'C:\\Python27\\lib\\lib-tk'
'C:\\Python27'
'C:\\Python27\\lib\\site-packages'
run_script 'report.py'
load_module '__main__' 'fp' 'report.py'
load_module 'binascii' None None
load_module -> Module('binascii')
ImportError: 'No module named suds'
ImportError: 'No module named suds'
load_module -> Module('__main__', 'report.py')
Name File
---- ----
m __main__ report.py
m binascii
Missing modules:
? suds.client imported from __main__
? suds.transport.https imported from __main__
是否有人成功使用 suds 包从脚本中使用 py2exe 构建了可执行文件?
操作系统:Windows 7 32位,Python:2.7,suds:0.4,py2exe 0.6.9
Attempting to build .exe using py2exe: python setup.py py2exe
, receiving error:
ImportError: No module named suds
I have done some research which suggests that the module(s) have to be specifically included in setup.py. Here is my setup.py:
from distutils.core import setup
import py2exe
setup(console = [{'script':'report.py'}],
options = {
'py2exe': {
'bundle_files' : 1,
'includes' : ['suds']
}
})
I've tried including the package names suds.client
, suds.transport.https
, but the error persists. py2exe seems to have several module specific requirements found here, but I do not see any suds specific documentation.
Found some information on how py2exe finds necessary modules here. The output of
C:\Python27>python -m py2exe.mf -d /path/to/report.py
path:
''
'C:\\Python27\\lib\\site-packages\\pyyaml-3.10-py2.7-win32.egg'
'C:\\Python27\\lib\\site-packages\\progressbar-2.3-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\sqlalchemy-0.7.2-py2.7-win32.egg'
'C:\\Python27\\lib\\site-packages\\soappy-0.12.5-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\wstools-0.3-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\fpconst-0.7.2-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\python_ntlm-1.0.1-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\django-1.3-py2.7.egg'
'C:\\Python27\\lib\\site-packages\\pyodbc-2.1.9-py2.7-win32.egg'
'C:\\Python27\\lib\\site-packages\\suds-0.4-py2.7.egg'
'C:\\Windows\\system32\\python27.zip'
'C:\\Python27\\DLLs'
'C:\\Python27\\lib'
'C:\\Python27\\lib\\plat-win'
'C:\\Python27\\lib\\lib-tk'
'C:\\Python27'
'C:\\Python27\\lib\\site-packages'
run_script 'report.py'
load_module '__main__' 'fp' 'report.py'
load_module 'binascii' None None
load_module -> Module('binascii')
ImportError: 'No module named suds'
ImportError: 'No module named suds'
load_module -> Module('__main__', 'report.py')
Name File
---- ----
m __main__ report.py
m binascii
Missing modules:
? suds.client imported from __main__
? suds.transport.https imported from __main__
Has anyone successfully built an executable with py2exe from a script using suds packages?
OS: Windows 7 32-bit, Python: 2.7, suds: 0.4, py2exe 0.6.9
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题不在于 py2exe,我已将其范围缩小到 py2exe/mf.py 中第 498 行的 imp.find_module 调用。
suds
模块导入正常,我可以在sys.path
中看到它,但报告未找到模块。
打开一个特定于
imp
模块的后续问题。Problem is not with py2exe, I've narrowed it down to the imp.find_module call at line 498 in py2exe/mf.py. The
suds
module imports OK, and I can see it insys.path
, butreports no module found.
Opening a followup question that is specific to
imp
module.一般来说,在安装脚本中导入所需的库可以帮助解决此类问题。在
import py2exe
行之后,尝试import suds
。Generally, importing required libraries inside of a setup script helps these kinds of problems. After the
import py2exe
line, tryimport suds
.