0
votes

I'm trying use py2exe to compile an eye tracking experiment written in Python 2.7 (32-bit). The experiment uses the psychopy library. I wrote the experiment using the PyCharm IDE, and the experiment runs when I run it through the PyCharm IDE, using an interpreter in a virtual environment located at C:\Users\phil\Python_2.7_32-bit.

The experiment compiles without generating any errors when I enter the following command into the command prompt: C:\Users\phil\Python_2.7_32-bit\Scripts\python.exe C:\Users\phil\PycharmProjects\iTRAC\VisSearch\setup.py py2exe.

When I run the executable generated by the above py2exe command, I get this error:

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'

My setup.py script is as follows:

from distutils.core import setup
import py2exe

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

I've also tried using the following setup.py script with the same results:

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,}}}])

I googled the error and came up with 0 results.

Can anybody tell me why I am running into this error?

1

1 Answers

0
votes

This is probably a missing config/prefs file. PsychoPy uses the configobj library to read and validate preferences but my guess is that py2exe is only automatically packaging py/pyc files and needs to include the .spec files in the psychopy/preferences folder.