ImportError: cannot import name QtCore

1,922 views
Skip to first unread message

Mark

unread,
Dec 19, 2015, 8:29:05 AM12/19/15
to psychopy-users
I've just updated from 1.83.01 to 1.83.03 and have problems running the demos timeByFrames.py and timeByframesEx.py.

The errors are similar for both demos and are below.  I'm running on a macbook air with OSX 10.11.2.  I fairly recently updated the mac from 10.11.1 to 10.11.2 so can't conclusively say if this is an OSX or psychopy issue but I definitely didn't have it with 1.83.01 and OSX 10.11.1.

Any ideas what might be the fix?
Many thanks.



Errors for timeByFrames.py -

##### Running: /Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/timing/timeByFrames.py #####
2015-12-19 13:23:16.533 python[22238:855960] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/15/sy3npcn55ms3dhyzbr2jmr4h0000gn/T/org.psychopy.PsychoPy2.savedState
Traceback (most recent call last):
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/timing/timeByFrames.py", line 16, in <module>
    import pylab
  File "pylab.pyc", line 1, in <module>
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/pylab.py", line 274, in <module>
    from matplotlib.pyplot import *
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/pyplot.py", line 109, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt4agg.py", line 17, in <module>
    from .backend_qt5agg import NavigationToolbar2QTAgg
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt5agg.py", line 18, in <module>
    from .backend_qt5 import QtCore
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt5.py", line 31, in <module>
    from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/qt_compat.py", line 91, in <module>
    from PyQt4 import QtCore, QtGui
ImportError: cannot import name QtCore

For timeByFramesEx.py -

##### Running: /Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/timing/timeByFramesEx.py #####
2015-12-19 13:24:49.615 python[22331:857044] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/15/sy3npcn55ms3dhyzbr2jmr4h0000gn/T/org.psychopy.PsychoPy2.savedState
Traceback (most recent call last):
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/timing/timeByFramesEx.py", line 32, in <module>
    import pylab
  File "pylab.pyc", line 1, in <module>
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/pylab.py", line 274, in <module>
    from matplotlib.pyplot import *
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/pyplot.py", line 109, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt4agg.py", line 17, in <module>
    from .backend_qt5agg import NavigationToolbar2QTAgg
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt5agg.py", line 18, in <module>
    from .backend_qt5 import QtCore
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt5.py", line 31, in <module>
    from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/qt_compat.py", line 91, in <module>
    from PyQt4 import QtCore, QtGui
ImportError: cannot import name QtCore

Jon Peirce

unread,
Dec 21, 2015, 12:14:56 PM12/21/15
to psychop...@googlegroups.com
Thanks for letting us know.

Some of the dependencies have been updated in the Standalone releases and, although they work on my machine it seems some of the updates aren't working everywhere. Looks like the version of the QT library (which is one option for opening windows/dialogs etc) isn't working universally. I'll try to work out why not.

Couple of workaround options:

    1. Avoid qt in favour of wx or tkinter. QT isn't used in many places - PsychoPy mostly uses wx instead. In the case of the script you're using here you could probably avoid it by adding this to the top of your script:
        import matplotlib
        matplotlib.use("WXAgg") #or "TKAgg"?

    2. Revert to the standalone from 1.83.01 if that was working for you and then just update the app with a patch release (download the zip file for version 1.83.03 and use the tools menu to update to this zip file). This way the depencies stay the same but you get the latest psychopy code

I'll try and sort out the root problem after christmas

Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/cbd6058f-47b3-4814-84e6-fe91cdd13ed8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jon Peirce
http://www.peirce.org.uk

Mark

unread,
Dec 21, 2015, 2:46:37 PM12/21/15
to psychopy-users
Jon,
Thanks for getting back to me.
I went back to 1.83.01 and then applied the 1.83.03 zip patch update and now all seems to be OK.
Thanks again,
Mark

Dan Dillon

unread,
Jul 6, 2016, 10:40:30 AM7/6/16
to psychopy-users
Picking up this old thread as (a) I was having a similar problem, (b) one of Jon's fixes worked, but (c) it's still a bit of a mystery to me so I figured it was worth reporting. I'm on OSX running 1.82.01 that's been updated with the 1.83.04 zip file. When I try the timeByFrames.py demo, I get the error below indicating that PySide can't be found--but I have PySide on my machine and I can import QtCore and QtGui from it in an ipython terminal just fine. I tried the first fix Jon suggested (using WXAgg) but that returns a prompt inside PsychoPy indicating that I need to upgrade wxPython to at least version 2.8, which is odd as I've got version 3.0.2.0 on my machine. The second fix Jon suggested (using TKAgg) worked immediately. I think there's probably a simple fix on my end for the wxPython thingbut not sure if there's some larger issue with the original PySide problem. Anyways, posting in case this helps somebody else with the same problem . . .

Dan

Here's the PySide error traceback:

  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/timing/timeByFrames.py", line 16, in <module>
    import pylab
  File "pylab.pyc", line 1, in <module>
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/pylab.py", line 269, in <module>
    from matplotlib.pyplot import *
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt4agg.py", line 13, in <module>
    from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/backend_qt4.py", line 25, in <module>
    from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/matplotlib/backends/qt4_compat.py", line 80, in <module>
    from PySide import QtCore, QtGui, __version__, __version_info__
ImportError: No module named PySide
Reply all
Reply to author
Forward
0 new messages