Refusing to import PyQt5 because PyQt4.QtCore is already imported.

750 views
Skip to first unread message

Soren Christensen

unread,
Jan 20, 2016, 6:38:08 PM1/20/16
to vispy
Hi,
 I wanted to give vispy a try and build SIP and PyQt from source.
I can import PyQt5 without errors.

If I try to use Vispy, it refuses to use PyQt5 as backend, apparently because PyQt4.QtCore is already loaded.  How can I prevent the Qt4 module from getting loaded?
(See below for 2 line example)
Thanks!
Soren


>>> import vispy
>>> vispy.use(app="PyQt5")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sorenc/.local/lib/python2.7/site-packages/vispy/util/wrappers.py", line 95, in use
    vispy.app.use_app(app)
  File "/home/sorenc/.local/lib/python2.7/site-packages/vispy/app/_default_app.py", line 47, in use_app
    default_app = Application(backend_name)
  File "/home/sorenc/.local/lib/python2.7/site-packages/vispy/app/application.py", line 49, in __init__
    self._use(backend_name)
  File "/home/sorenc/.local/lib/python2.7/site-packages/vispy/app/application.py", line 218, in _use
    raise RuntimeError(msg)
RuntimeError: Could not import backend "PyQt5":
Refusing to import PyQt5 because PyQt4.QtCore is already imported.

Soren Christensen

unread,
Jan 22, 2016, 2:22:14 PM1/22/16
to vispy
0 views in 2 days!
What did I do wrong?

Soren Christensen

unread,
Jan 25, 2016, 2:29:00 PM1/25/16
to vispy
It turns out the problem comes from launching the code from spyder.  Apparently the Qt4 module is somehow detected as loaded when I run it this way. If I run from cmd line it works.
I still don't have a solution for using spyder in case anyone has any ideas.

Thanks!

Luke Campagnola

unread,
Jan 26, 2016, 1:29:32 AM1/26/16
to Vispy list
You did nothing wrong, Soren. We're just busy people  ;)

The problem is that when you run your script from Spyder, it imports several packages into the running process (presumably for debugging purposes), one of which is PyQt4. I am not even sure if it is possible to use both Qt5 and Qt4 in the same process. Perhaps there is a way to get spyder to launch your code without modifying it, though..

--
You received this message because you are subscribed to the Google Groups "vispy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vispy+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Soren Christensen

unread,
Jan 28, 2016, 10:27:23 PM1/28/16
to vi...@googlegroups.com

Thanks!
That is helpful. I will return with an update once I get a chance to investigate.

Soren

You received this message because you are subscribed to a topic in the Google Groups "vispy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vispy/dy3RqHDarJg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vispy+un...@googlegroups.com.

Soren Christensen

unread,
Feb 1, 2016, 5:32:20 PM2/1/16
to vi...@googlegroups.com
For others with this problem: Turns out it was spyder doing a default import that include qt4 - see here for how to disable/change the path:
in short:Tools > Preferences > Console > Advanced Settings > PYTHONSTARTUP replacement

Luke Campagnola

unread,
Feb 1, 2016, 5:39:34 PM2/1/16
to Vispy list
Thanks Soren!

Traveler Hauptman

unread,
Sep 28, 2017, 10:02:32 PM9/28/17
to vispy
Thanks soren!
Reply all
Reply to author
Forward
0 new messages