psychopy.org | Reference | Downloads | Github

Import Error with PyQt5


#1

Hello,

I recently upgraded Psychopy on my computer (Mac OS X version 10.6.8) to v1.85.2, however when I tried running one of my scripts I received the following error:

Traceback (most recent call last):
  File "/Users/dscnlab/Desktop/TRW_scan_comp/TRW_comp.py", line 18, in <module>
    from psychopy import locale_setup, visual, core, data, event, logging, sound, gui, microphone
  File "/Volumes/PsychoPy 1/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/gui/__init__.py", line 32, in <module>
    from .qtgui import *
  File "/Volumes/PsychoPy 1/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/gui/qtgui.py", line 14, in <module>
    from PyQt5 import QtWidgets
ImportError: No module named PyQt5

I tried installing PyQt5 through the terminal with pip install pyqt5, but this didn’t work either. Is there a way I can either install PyQt5 such that Psychopy can import it, or is there a different workaround I should be using?

Thank you for your assistance.


#2

Correction: the upgraded Psychopy version is v1.84.2


#3

I’m having this same problem with a failure to import from pyqt5 in an old Mac os. Any ideas?


#4

This is the error I’m getting:

Running: /Users/erin/Desktop/Exclusion_Aggression/Working Cyberball PG.py

pyo version 0.8.6 (uses single precision)
Traceback (most recent call last):
File “/Users/erin/Desktop/Exclusion_Aggression/Working Cyberball PG.py”, line 14, in
from psychopy import locale_setup, sound, gui, visual, core, data, event, logging
File “/Users/erin/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/gui/init.py”, line 32, in
from .qtgui import *
File “/Users/erin/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/gui/qtgui.py”, line 14, in
from PyQt5 import QtWidgets
ImportError: No module named PyQt5

This is the block of code it refers to:
try:
from PyQt4 import QtGui
QtWidgets = QtGui # in qt4 these were all in one package
from PyQt4.QtCore import Qt
except Exception:
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5.QtCore import Qt


#5

It seems the problem is that what I assume is a standard python package on psychopy, PyQt5, is not installed on the MacBook. It seems tricky to install packages in psychopy, especially on Macs, and the standard pip install PyQt5 doesn’t work. Can anyone suggest how I could install PyQt5 to resolve this problem.