【问题标题】:compiling python script to exe with py2exe, getting error使用py2exe将python脚本编译为exe,出现错误
【发布时间】:2017-02-10 17:07:54
【问题描述】:

所以我有一个名为 papercutter.py 的脚本和一个 setup.py 根据 py2exe 教程设置如下:

from distutils.core import setup
import py2exe

setup(console=['papercutter.py'])

所以按照教程,我运行 python setup.py py2exe 看起来很成功:

c:\Codes>python setup.py install
running install
running build
running install_egg_info
Removing C:\Python\Lib\site-packages\UNKNOWN-0.0.0-py3.6.egg-info
Writing C:\Python\Lib\site-packages\UNKNOWN-0.0.0-py3.6.egg-info

但是当我运行下一步时,python setup.py py2exe,我得到错误:

c:\Codes>python setup.py py2exe
running py2exe
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    setup(console=['papercutter.py'])
  File "C:\Python\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Python\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Python\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Python\lib\site-packages\py2exe\distutils_buildexe.py", line 188,        in run
    self._run()
  File "C:\Python\lib\site-packages\py2exe\distutils_buildexe.py", line 267,      in _run
    builder.analyze()
  File "C:\Python\lib\site-packages\py2exe\runtime.py", line 157, in analyze
    self.mf.import_package(modname[:-2])
  File "C:\Python\lib\site-packages\py2exe\mf3.py", line 91, in      import_package
    self.import_hook(name)
  File "C:\Python\lib\site-packages\py2exe\mf3.py", line 117, in import_hook
    module = self._gcd_import(name)
  File "C:\Python\lib\site-packages\py2exe\mf3.py", line 267, in _gcd_import
    return self._find_and_load(name)
  File "C:\Python\lib\site-packages\py2exe\mf3.py", line 320, in _    find_and_load
    self._scan_code(module.__code__, module)
  File "C:\Python\lib\site-packages\py2exe\mf3.py", line 352, in _scan_code
    for what, args in self._scan_opcodes(code):
  File "C:\Python\lib\site-packages\py2exe\mf3.py", line 381, in     _scan_opcodes
    yield "store", (names[oparg],)
IndexError: tuple index out of range

我在这里做错了什么?

注意:这是我正在学习的教程:http://www.py2exe.org/index.cgi/Tutorial

另请注意:我使用的是 py2exe 0.9.2.0 和 python 3.6.0。我认为这些应该很好。

【问题讨论】:

    标签: python selenium py2exe helium


    【解决方案1】:

    答案在 Traceback 的底部。好像你有一个元组的索引问题。在 Python 中索引为 0。

    【讨论】:

    【解决方案2】:

    目前 py2exe 最高支持 Python 3.4

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-04
      • 2014-05-15
      • 1970-01-01
      • 2017-09-01
      相关资源
      最近更新 更多