Cython Error with installation of psychopy package on Mac Silicon

I am attempting to use the psychopy package (version 2023.2.3), and it appears to install some psychtoolbox files alongside itself. On running import psychtoolbox as ptb with Mac Silicon, I get:

ImportError                               Traceback (most recent call last)
Cell In[57], [line 1](vscode-notebook-cell:?execution_count=57&line=1)
----> [1](vscode-notebook-cell:?execution_count=57&line=1) import psychtoolbox as ptb

File [~/miniforge3/envs/goodfeeling/lib/python3.10/site-packages/psychtoolbox/__init__.py:28](https://file+.vscode-resource.vscode-cdn.net/Users/davidcsuka/Documents/nanoGPT/~/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/__init__.py:28)
     [26](file:///Users/davidcsuka/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/__init__.py?line=25) from .WaitSecs import WaitSecs
     [27](file:///Users/davidcsuka/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/__init__.py?line=26) from .GetSecs import GetSecs
---> [28](file:///Users/davidcsuka/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/__init__.py?line=27) from .PsychHID import PsychHID
     [29](file:///Users/davidcsuka/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/__init__.py?line=28) from .IOPort import IOPort
     [30](file:///Users/davidcsuka/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/__init__.py?line=29) if is_64bits:

ImportError: dlopen(/Users/davidcsuka/miniforge3/envs/myenv/lib/python3.10/site-packages/psychtoolbox/PsychHID.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_AllocateHIDObjectFromIOHIDDeviceRef'

The same thing happens with python 3.9, and with Python 3.8 (recommended) the psychopy installation doesn’t even work in pip due to:

File "/private/var/folders/9x/x950xm6j3ws6cm5rcv8w34kh0000gn/T/pip-build-env-a0oj0w5k/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/9x/x950xm6j3ws6cm5rcv8w34kh0000gn/T/pip-build-env-a0oj0w5k/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 928, in <module>
        File "<string>", line 923, in get_cython_extfiles
        File "/private/var/folders/9x/x950xm6j3ws6cm5rcv8w34kh0000gn/T/pip-build-env-a0oj0w5k/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "/private/var/folders/9x/x950xm6j3ws6cm5rcv8w34kh0000gn/T/pip-build-env-a0oj0w5k/overlay/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: tables/utilsextension.pyx
      [end of output]

Do I perhaps need to use some different version of Cython, or are various C compilers incompatible with each other? Or maybe this pertains to my operating system?

  • the first error indicates that there’s something wrong with from .PsychHID import PsychHID. I don’t believe the package has installed correctly given: PsychHID.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_AllocateHIDObjectFromIOHIDDeviceRef'. If that’s what’s causing the compilation issues, that has nothing to do with Cython. Tbh I’m not sure if that specific package is supported on ARM (apple silicon) but try to use it in bare Python first and see if that works.

    – 

  • @OM222O The file in question PsychHID.cpython-310-darwin.so is a .so file, which apparently is binary so could I still run it in bare Python? I can’t get it to open. The name of the file also has Cython in it. Thanks for your help.

    – 

  • CPython ia not Cython, it’s the main distribution of Python. There are other implementations like PyPy, Pyston and even bastardizations like Jython (JVM (java) Python). And by “can you run it” I meant Psychopy as a whole. If yes, try to use somethint that imports/calls to the .so file in question.

    – 




Leave a Comment