Trouble running PsychoPy in Anaconda

Hi, I am quite new to this and I am trying to install and run PsychoPy in an Anaconda environment. I followed the instructions given on Installation — PsychoPy v2022.2.3. I created a .yaml file with the environment information and stored it in a folder. I navigated to that folder in the Anaconda prompt and when I ran the provided code conda env create -n psychopy -f psychopy-env.yml, everything seemed to run correctly. conda activate psychopy also worked but when I then try to open the application by running psychopy, I get some error messages:

(psychopy) C:\Users\leonb\OneDrive\Uni - Onedrive\Spinoza\Anaconda>psychopy
pygame 2.1.2 (SDL 2.0.18, Python 3.6.15)
Hello from the pygame community. https://www.pygame.org/contribute.html
C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\pyglet\media\codecs\wmf.py:838: UserWarning: [WinError -2147417850] Cannot change thread mode after it is set
  warnings.warn(str(err))
PTB-INFO: Using modified PortAudio V19.7.0-devel, revision unknown
Traceback (most recent call last):
  File "C:\Users\leonb\anaconda3\envs\psychopy\Scripts\psychopy-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\psychopy\app\psychopyApp.py", line 100, in main
    start_app()
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\psychopy\app\psychopyApp.py", line 22, in start_app
    from psychopy.app._psychopyApp import PsychoPyApp
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\psychopy\app\_psychopyApp.py", line 55, in <module>
    from psychopy import projects
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\psychopy\projects\__init__.py", line 11, in <module>
    from . import pavlovia
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\psychopy\projects\pavlovia.py", line 30, in <module>
    import gitlab
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\gitlab\__init__.py", line 23, in <module>
    from gitlab import utils as _utils
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\gitlab\utils.py", line 9, in <module>
    from gitlab import types
  File "C:\Users\leonb\anaconda3\envs\psychopy\lib\site-packages\gitlab\types.py", line 1, in <module>
    import dataclasses
ModuleNotFoundError: No module named 'dataclasses'
14.0437         WARNING         Speech-to-text recognition module not available (use command `pip install SpeechRecognition` to get it. Transcription will be unavailable.
14.1130         WARNING         We strongly recommend you activate the PTB sound engine in PsychoPy prefs as the preferred audio engine. Its timing is vastly superior. Your prefs are currently set to use ['sounddevice', 'PTB', 'pyo', 'pygame'] (in that order).

I really recommend you install PsychoPy as a standalone installation and keep it separate from your conda install (which you could still use for your analysis etc)

That said, the issue you’ve got appears to be due to using Python3.6, whereas we now recommend Python3.8. It looks like the gitlab library now requires dataclasses lib, which was only added in Py3.7, so you’ll be out of luck for now, trying to use conda python 3.6

Thanks for the help! When I enter python -V in my base environment I get Python 3.9.12. In my psychopy environment I get 3.6.15. I am not sure why that is? I tried using conda install python=3.9 within my psychopy environment. This resulted in many conflicts and in the end the version did not change.
I guess I am best off with a clean reinstall? How do I avoid my Python version being put to 3.6 when installing psychopy?

So I discovered that the environment file provided on the website (Installation — PsychoPy v2022.2.4) specifies the python version to be 3.6. Maybe this is worth updating!

I changed the environment file to say 3.9 now and everything works well.

1 Like

Hi @leonsbe
The installation page has been updated to indicate 3.8 which is the version we now typically use. That’s the version that currently has widest support (e.g. from hardware manufacturers). I’ve also updated the conda environment file to indicate 3.8. Hopefully that works as well as 3.9 :slight_smile: