每当我使用python demo_2.py py2exe
运行代码时,它都会给我这个错误。
C:\CarlomanSystems>python setup.py py2exe
running py2exe
Traceback (most recent call last):
File "setup.py", line 3, in <module>
setup(console=['filw-1.py'])
File "C:\Python35\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python35\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python35\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python35\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Python35\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Python35\lib\site-packages\py2exe\runtime.py", line 158, in analyze
self.mf.import_package(modname[:-2])
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 98, in import_package
self.safe_import_hook("%s.%s" % (name, modname))
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 401, in _scan_code
self._scan_code(c, mod)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 401, in _scan_code
self._scan_code(c, mod)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 401, in _scan_code
self._scan_code(c, mod)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 401, in _scan_code
self._scan_code(c, mod)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 394, in _scan_code
self.safe_import_hook(name, mod, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
self.import_hook(name, caller, fromlist, level)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 288, in _find_and_load
self._gcd_import(parent)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 356, in _find_and_load
if module.__code__:
File "C:\Python35\lib\site-packages\py2exe\mf3.py", line 622, in __code__
self.__code_object__ = self.__loader__.get_code(self.__name__)
File "<frozen importlib._bootstrap_external>", line 764, in get_code
File "<frozen importlib._bootstrap_external>", line 724, in source_to_code
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes
我也尝试了cx_freeze,但它给了我同样的错误。
我的源代码只有一行,即:
print('hello world!')
我用notepad ++打开了它,但它没有显示任何空字符。 我卸载并重新安装库py2exe和cx_freeze,但它没有解决问题。
答案 0 :(得分:0)
2016年11月仍然没有Python 3.5和py2exe最新的支持。 试试这个 http://cx-freeze.readthedocs.io/en/latest/overview.html