Running python script with psychopy modules from Windows cmd

Hi there,

I am trying to run my python script from my Windows terminal. I remember doing it without any issues from my Linux system, but somehow now it does not recognise the psychopy library and I can’t seem to import any of the psychopy modules.

C:\Windows\System32>python
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb  7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> from psychopy import core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'psychopy'

When I try to run my script, it says this:

C:\Windows\System32>C:\Program Files\PsychoPy\python.exe C:\Users\Leila\Desktop\ImageRatingTask_testB.py

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

When I check if psychopy is installed - which I did downloading the standalone first, and then via pip install to check if it made a difference - it seems to exist (although pyo seems to have some trouble…):

C:\Windows\System32>pip install psychopy
Collecting psychopy
  Using cached PsychoPy-2022.2.5.zip (26.1 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: requests[security] in c:\users\leila\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from psychopy) (2.28.1)
Collecting cryptography
  Using cached cryptography-39.0.1-cp36-abi3-win_amd64.whl (2.5 MB)
Requirement already satisfied: numpy<1.24.0 in c:\users\leila\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from psychopy) (1.23.3)
Collecting scipy
  Using cached scipy-1.10.0-cp310-cp310-win_amd64.whl (42.5 MB)
Collecting matplotlib
  Using cached matplotlib-3.6.3-cp310-cp310-win_amd64.whl (7.2 MB)
Collecting pandas
  Using cached pandas-1.5.3-cp310-cp310-win_amd64.whl (10.4 MB)
Requirement already satisfied: pillow in c:\users\leila\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from psychopy) (9.4.0)
Collecting glfw
  Using cached glfw-2.5.6-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-win_amd64.whl (493 kB)
Collecting pygame
  Using cached pygame-2.1.2-cp310-cp310-win_amd64.whl (8.4 MB)
Collecting pyo
  Using cached pyo-1.0.4.tar.gz (6.1 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\Leila\AppData\Local\Temp\pip-install-v8wbq75i\pyo_9462bbb9c75e430e8ef9bc6e96d1ad7d\setup.py", line 293, in <module>
          for f in os.listdir(data_files_common_path)
      FileNotFoundError: [WinError 3] The system cannot find the path specified: 'win64dlls\\win64_pyo_data_files_common'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
type or paste code here

Would any of you have any clue about what could be going wrong?

Thanks!!

Best,

Leila

There are a few modules in PsychoPy’s dependencies that don’t play nice. See here for some possible solutions: Issues with Developer's Install on Windows 11 with Py 3.10

1 Like