简体   繁体   中英

Importing qtopengl in to Python 3 on Ubuntu 14.04

This is related to this question but applicable to Python 3 rather than 2.x

I am trying to run the pyqtgraph example programs under Python 3.4 (Ubuntu 14.04). When I try to run the surface-plotting example I get:

tim@MERLIN:/usr/local/lib$ python3 -m pyqtgraph.examples
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/pyqtgraph-0.9.8-py3.4.egg/pyqtgraph/examples/GLSurfacePlot.py", line 12, in <module>
    import pyqtgraph.opengl as gl
  File "/usr/local/lib/python3.4/dist-packages/pyqtgraph-0.9.8-py3.4.egg/pyqtgraph/opengl/__init__.py", line 1, in <module>
    from .GLViewWidget import GLViewWidget
  File "/usr/local/lib/python3.4/dist-packages/pyqtgraph-0.9.8-py3.4.egg/pyqtgraph/opengl/GLViewWidget.py", line 1, in <module>
    from pyqtgraph.Qt import QtCore, QtGui, QtOpenGL
ImportError: cannot import name 'QtOpenGL'

Can anyone suggest what is the best way to go about installing this for Python 3 (it works great under Python 2.7)?

I just discovered that pyqtgraph, in some case, does not correctly import the python qt libs. Try to add at the beginning of your code:

import PySide

or

import PyQt5

even

import PyQt4

depending on which library you want to use by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM