【问题标题】:Error running executable compiled with py2exe运行使用 py2exe 编译的可执行文件时出错
【发布时间】:2016-07-28 18:44:59
【问题描述】:

我正在尝试使用 py2exe 编译一个用 Python 2.7(32 位)编写的眼动追踪实验。实验使用了psychopy 库。我使用 PyCharm IDE 编写了这个实验,当我通过 PyCharm IDE 运行它时,实验运行,使用位于C:\Users\phil\Python_2.7_32-bit 的虚拟环境中的解释器。

当我在命令提示符中输入以下命令时,实验编译没有产生任何错误:C:\Users\phil\Python_2.7_32-bit\Scripts\python.exe C:\Users\phil\PycharmProjects\iTRAC\VisSearch\setup.py py2exe

当我运行上述 py2exe 命令生成的可执行文件时,我收到此错误:

Traceback (most recent call last):
  File "VisualSearch.py", line 3, in <module>
  File "psychopy\__init__.pyc", line 39, in <module>
  File "psychopy\preferences\__init__.pyc", line 5, in <module>
  File "psychopy\preferences\preferences.pyc", line 172, in <module>
  File "psychopy\preferences\preferences.pyc", line 33, in __init__
  File "psychopy\preferences\preferences.pyc", line 98, in loadAll
  File "psychopy\preferences\preferences.pyc", line 146, in loadAppData
  File "psychopy\preferences\configobj.pyc", line 583, in __getitem__
KeyError: 'builder'

我的 setup.py 脚本如下:

from distutils.core import setup
import py2exe

setup(windows =['C:\Users\phil\PycharmProjects\iTRAC\VisSearch\VisualSearch.py'])

我也尝试过使用以下 setup.py 脚本,结果相同:

from distutils.core import setup
import py2exe

setup(windows = [{'script':'C:\Users\phil\PycharmProjects\iTRAC\VisSearch\VisualSearch.py',
                  'options' : {'py2exe':{'includes':['psychopy'],
                                         'compressed': True,
                                         'bundle_files': 1,}}}])

我用谷歌搜索了错误并得出了 0 个结果。

谁能告诉我为什么会遇到这个错误?

【问题讨论】:

    标签: python windows compiler-errors py2exe psychopy


    【解决方案1】:

    这可能是缺少配置/首选项文件。 PsychoPy 使用 configobj 库来读取和验证首选项,但我的猜测是 py2exe 只会自动打包 py/pyc 文件,并且需要将 .spec 文件包含在 Psychopy/preferences 文件夹中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-14
      • 2013-08-16
      • 2021-08-19
      • 2015-05-04
      • 1970-01-01
      • 2016-11-21
      • 1970-01-01
      相关资源
      最近更新 更多