When running timesByFrames in PsychoPy 3.0.0b10 on Windows 10, I get the following error:
##### Running: C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\demos\coder\timing\timeByFrames.py #####
Traceback (most recent call last):
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\demos\coder\timing\timeByFrames.py", line 23, in <module>
import pylab
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\pylab.py", line 252, in <module>
from matplotlib import cbook, mlab, pyplot as plt
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\pyplot.py", 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\__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 9, in <module>
from .backend_qt5agg import (
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 15, in <module>
from .backend_qt5 import (
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\backend_qt5.py", 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\figureoptions.py", 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\formlayout.py", line 54, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\matplotlib\backends\qt_compat.py", line 153, in <module>
from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named 'PyQt4'
Naturally, I get the same in timeByFramesEx.py, also becase the pylab --> matplotlib --> Qt4 dependency. Deleting the pylab import, the other parts of the demo runs fine. So it seems to be a pure packaging problem.
In the latest versions of PsychoPy we're packaging PyQt5 instead of PyQt4. Setting matplotlib to use PyQt5 in your case will probably be optimal, but leaving it blank (I think that defaults to use TkAgg backend) will probably be fine.
I'm not sure what we should do in the demo, given that matplotlib doesn't do any nice fallback-to-default actions. Maybe we have a try...except in the demo?
Yeah, I was mostly worried about the average user running this and being confused by a failing demo. Maybe we can use something else than matplotlib entirely. I'm not up to date on python plotting modules, though.
This problem should go away with the just-released Matplotlib 3.0, but it's Python 3-only.
OK, I'll start providing MPL 3.0.0 as part of Python3 builds from now on. @hoechenberger will be glad to know that I can't currently build the 2.7 releases on Mac so Mac users are currently forced into Python3.6 Standalone anyway.
And I'll remove the matplotlib.use lines from the demo
laughing Hey, I don't mind Python 2.7 builds ;) But seriously, _does_ MPL 3 actually fix this issue? It was just speculation from my side, without further testing!
hehehe
I haven't actually tried yet, but I'll give it a go. Either way, updating it in the standalone is the right thing to do.
MPL3 does sort of fix it. There, if you ask for Qt4 and it finds Qt5 it will switch to that. So I've left the demo the same and we'll allow MPL to handle the switch if Qt4 not present. That means, as Richard says, that the fix only works form Py3, but that's OK too because in Py2 I think we are shipping with Qt4 in the standalone so the demo should work there too.
Fixed in 3.0.0b11
I can confirm that it's fixed!
Most helpful comment
OK, I'll start providing MPL 3.0.0 as part of Python3 builds from now on. @hoechenberger will be glad to know that I can't currently build the 2.7 releases on Mac so Mac users are currently forced into Python3.6 Standalone anyway.