本文介绍了使用Py2Exe将pyscript转换为exe时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是这个py2exe的新手,
I am new to this py2exe,
我的脚本在cmd.py中
I have my script in cmd.py
import sys
for arg in sys.argv:
print arg
print "Hello World!"
setup.py,
from distutils.core import setup
import py2exe
setup(console=['cmd.py'])
将两个文件放在同一目录中,
having both the files in same directory,
我跑了,
python setup.py py2exe
并获得以下错误,
G:\PyScripts>python setup.py py2exe
running py2exe
Traceback (most recent call last):
File "setup.py", line 3, in <module>
setup(console=['cmd.py'])
File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\ProgramData\Anaconda3\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
请提供帮助,提前致谢!
Please help on this, Thanks in Advance!
推荐答案
检查你的python版本是3请用python版本2试试,因为py2exe是为python2开发的
Check your python version if it is 3 please try it with python version 2 because py2exe is developed for python2
这篇关于使用Py2Exe将pyscript转换为exe时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!