我在Windows XP上重新安装了python2.7。 我安装了:
以下代码有效,文件为hello.py:
import sympy if __name__ == '__main__': print "hello world of sympy"
from distutils.core import setup import py2exe setup(console=['hello.py'])
python py2exe hello.py
给出了以下错误:Traceback (most recent call last): File "setup.py", line 4, in <module> setup(console=['hello.py']) File "C:\Python27\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands self.run_command(cmd) File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 243, in run self._run() File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 296, in _run self.find_needed_modules(mf, required_files, required_modules) File "C:\Python27\lib\site-packages\py2exe\build_exe.py", line 1277, in find_needed_modules mf.run_script(path) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 713, in run_script Base.run_script(self, pathname) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 124, in run_script self.load_module('__main__', fp, pathname, stuff) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 730, in load_module r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ)) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 314, in load_module self.scan_code(co, m) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 423, in scan_code self._safe_import_hook(name, m, fromlist, level=level) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_hook self.import_hook(name, caller, level=level) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 719, in import_hook return Base.import_hook(self,name,caller,fromlist,level) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 136, in import_hook q, tail = self.find_head_package(parent, name) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 192, in find_head_package q = self.import_module(head, qname, parent) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 724, in import_module r = Base.import_module(self,partnam,fqname,parent) File "C:\Python27\lib\site-packages\py2exe\mf.py", line 284, in import_module m = self.load_module(fqname, fp, pathname, stuff)
....等,消息以:
结束 r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 314, in load_module
self.scan_code(co, m)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 423, in scan_code
self._safe_import_hook(name, m, fromlist, level=level)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_hook
self.import_hook(name, caller, level=level)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 719, in import_hook
return Base.import_hook(self,name,caller,fromlist,level)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 137, in import_hook
m = self.load_tail(q, tail)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 214, in load_tail
m = self.import_module(head, mname, m)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 724, in import_module
r = Base.import_module(self,partnam,fqname,parent)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 284, in import_module
m = self.load_module(fqname, fp, pathname, stuff)
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 730, in load_module
r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
File "C:\Python27\lib\site-packages\py2exe\mf.py", line 293, in load_module
self.msgin(2, "load_module", fqname, fp and "fp", pathname)
RuntimeError:超出最大递归深度
所以,我不能用简单的程序创建exe。有人知道下一步该怎么办?有什么需要检查的吗?