Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Module backends._qt" should not be imported directly #1261

Closed
fuchstraumer opened this issue Jul 26, 2016 · 2 comments
Closed

"Module backends._qt" should not be imported directly #1261

fuchstraumer opened this issue Jul 26, 2016 · 2 comments

Comments

@fuchstraumer
Copy link

Hello - I'm trying to get vispy to work with pyqt5 and I'm having a hell of a time. here's the header of my code where I import the various libraries:

import sys
sys.path.insert(0,'../lib/')
from pyqt5.QtWidgets import (QMainWindow,QTextEdit,QAction,QFileDialog,QApplication,qApp)
from pyqt5 import QtGui,QtCore
from numpy_stl import mesh
from vispy.app import timer, backends
from vispy.scene import visuals, SceneCanvas
from vispy.scene.widgets import ViewBox

Since this error is being thrown up, I've tried importing the vispy parts first and the PyQt bits last, and I still get the same error. I'm completely boggled and stuck, and have no idea what's wrong. I'm not sure if its a bug (and if its not, sorry for submitting a non-issue) but any help with figuring this out would be wonderful and highly appreciated.

The exact error is:
" File "../lib/vispy\app\qt.py", line 29, in
raise RuntimeError("Module backends._qt should not be imported directly.")
RuntimeError: Module backends._qt should not be imported directly."

Based on the qt.py code at this line, it suggests to me that its not importing or finding the right library? I'm using pyqt5 and it imports fine for use elsewhere. Do I need to tell the qt.py module to search in my project lib folder by using sys.path.insert or something?

@pevhall
Copy link

pevhall commented Nov 10, 2016

Hi I fixed this problem by adding these two lines at the beginning of my program (it may work for you).

import vispy
vispy.use('PyQt5')

I'm using PyQt5 and Python3.7 on windows10

@djhoese
Copy link
Member

djhoese commented Oct 30, 2017

I'm not able to reproduce this with the newest version of vispy. If you can please reopen this. I tried:

from PyQt5.QtWidgets import (QMainWindow,QTextEdit,QAction,QFileDialog,QApplication,qApp)
from PyQt5 import QtGui,QtCore,QtWidgets
#from numpy_stl import mesh
from vispy.app import timer, backends
from vispy import app
from vispy.scene import visuals, SceneCanvas
from vispy.scene.widgets import ViewBox


app.create()
w = QtWidgets.QWidget()
w.show()
app.run()

And it worked. Note that app.create() has essentially the same result as calling use_app which is to create the default Application backend.

@djhoese djhoese closed this as completed Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants