| Reference | Downloads | Github demo not working with the new v3.1.0 release (no module named PyQt4)

Hi Guys,
I just installed the new v3.1 release (fantastic job for the new keyboard class). The timeByFrames demo of the coder is broken and returns the error reported below. I think it is important to fix it because the demo is very useful to check the precision of frame flips. The bug seems to concern pylab.

Note that I installed PsychoPy using the standalone program, and I am running windows 10.

Problem compiling: [Errno 13] Permission denied: 'C:\\Program Files (x86)\\PsychoPy3\\lib\\site-packages\\psychopy\\demos\\coder\\timing\\__pycache__\\timeByFrames.cpython-36.pyc.2834910788104'
##### Running: C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\demos\coder\timing\ #####
pygame 1.9.4
Hello from the pygame community.
Traceback (most recent call last):
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\demos\coder\timing\", line 23, in <module>
    import pylab
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\", line 1, in <module>
    from matplotlib.pylab import *
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\", line 252, in <module>
    from matplotlib import cbook, mlab, pyplot as plt
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\", line 62, in pylab_setup
    [backend_name], 0)
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\", line 9, in <module>
    from .backend_qt5agg import (
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\", line 15, in <module>
    from .backend_qt5 import (
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\", line 19, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\qt_editor\", line 20, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\qt_editor\", line 54, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\", line 153, in <module>
    from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named 'PyQt4'

(putting aside I’m not sure if they fixed this in 3.1.2, or I had done something here to fix)
If you put matplotlib.use('Qt5Agg') in line 22, you should be good to go.

I’m having the same issue on v3.1.2 on Win10.

Apologies. I keep forgetting to update the demo code but, yes, @mirh has the right solution. Change the code to use ‘Qt5Agg’ (and save somewhere that you have write permissions) and you should be good to go.