ImportError: No module named suds
Having trouble with py2exe importing the suds module, and narrowed i开发者_运维问答t down to the following:
>>> imp.find_module('suds', sys.path)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named suds
However, a simple import works fine:
>>> import suds
>>> suds.__version__
'0.4'
Here is my sys.path, which shows suds at 'C:\Python27\lib\site-packages\suds-0.4-py2.7.egg':
>>> pprint.pprint(sys.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']
Confirmed that py2exe is installed under 2.7:
C:\Python27\Lib\site-packages>ls -l py2*
-rw-rw-rw- 1 BEARGLE 0 524 2008-11-10 14:40 py2exe-0.6.9-py2.7.egg-info
py2exe:
total 448
-rw-rw-rw- 1 BEARGLE 0 3092 2008-11-10 14:39 __init__.py
-rw-rw-rw- 1 BEARGLE 0 3177 2011-09-12 14:36 __init__.pyc
-rw-rw-rw- 1 BEARGLE 0 3177 2011-09-12 14:35 __init__.pyo
-rw-rw-rw- 1 BEARGLE 0 4582 2008-06-24 16:32 boot_com_servers.py
-rw-rw-rw- 1 BEARGLE 0 2898 2011-09-12 14:35 boot_com_servers.pyc
-rw-rw-rw- 1 BEARGLE 0 2898 2011-09-12 14:35 boot_com_servers.pyo
-rw-rw-rw- 1 BEARGLE 0 3584 2008-06-24 16:32 boot_common.py
-rw-rw-rw- 1 BEARGLE 0 2252 2011-09-12 14:35 boot_common.pyc
-rw-rw-rw- 1 BEARGLE 0 2252 2011-09-12 14:35 boot_common.pyo
-rw-rw-rw- 1 BEARGLE 0 2941 2008-06-24 16:32 boot_ctypes_com_server.py
-rw-rw-rw- 1 BEARGLE 0 2733 2011-09-12 14:35 boot_ctypes_com_server.pyc
-rw-rw-rw- 1 BEARGLE 0 2733 2011-09-12 14:35 boot_ctypes_com_server.pyo
-rw-rw-rw- 1 BEARGLE 0 7527 2008-06-24 16:32 boot_service.py
-rw-rw-rw- 1 BEARGLE 0 5081 2011-09-12 14:35 boot_service.pyc
-rw-rw-rw- 1 BEARGLE 0 4973 2011-09-12 14:35 boot_service.pyo
-rw-rw-rw- 1 BEARGLE 0 71838 2008-08-30 11:56 build_exe.py
-rw-rw-rw- 1 BEARGLE 0 48498 2011-09-12 14:35 build_exe.pyc
-rw-rw-rw- 1 BEARGLE 0 48330 2011-09-12 14:35 build_exe.pyo
-rw-rw-rw- 1 BEARGLE 0 30327 2011-09-13 09:16 mf.py
-rw-rw-rw- 1 BEARGLE 0 22999 2011-09-13 09:16 mf.pyc
-rw-rw-rw- 1 BEARGLE 0 22876 2011-09-12 14:35 mf.pyo
-rw-rw-rw- 1 BEARGLE 0 13312 2008-11-10 14:40 py2exe_util.pyd
drw-rw-rw- 2 BEARGLE 0 4096 2011-09-12 14:35 resources
-rwxrwxrwx 1 BEARGLE 0 17408 2008-11-10 14:40 run.exe
-rw-rw-rw- 1 BEARGLE 0 19456 2008-11-10 14:40 run_ctypes_dll.dll
-rw-rw-rw- 1 BEARGLE 0 19968 2008-11-10 14:40 run_dll.dll
-rw-rw-rw- 1 BEARGLE 0 20480 2008-11-10 14:40 run_isapi.dll
-rwxrwxrwx 1 BEARGLE 0 17408 2008-11-10 14:40 run_w.exe
drw-rw-rw- 8 BEARGLE 0 4096 2011-09-12 14:35 samples
Why isn't imp.find_module locating the suds module?
Extracted the suds
egg at:
C:\Python27\lib\site-packages\suds-0.4-py2.7.egg
and created C:\Python27\lib\site-packages\suds
directory that contains source files. Module is now found:
>>> imp.find_module('suds')
(None, 'C:\\Python27\\lib\\site-packages\\suds', ('', '', 5))
py2exe build completes successfully. It appears that imp.find_module
requires directory with module source files to exist, an egg file is not recognized.
精彩评论