4

I recently downloaded PyQtGraph and am using Python 2.7. I am attempting to run the simple example from the documentation:

import pyqtgraph.examples
pyqtgraph.examples.run()

However, when I attempt to import the package in iPython or in a script, I am greeted with the following error:

Exception: PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.

I've installed PyQt5 via Homebrew (as it wasn't able to do so with PySide or PyQt4) but I still get the same error. When I attempt to import any of these packages I get a similar error telling me that they can't be imported. Here is my traceback when I attempt to import PyQtGraph:

    In [1]: import pyqtgraph as pg
-----------------------------------------------------------
Exception                 Traceback (most recent call last)
<ipython-input-1-e5a51b506085> in <module>()
----> 1 import pyqtgraph as pg

/usr/local/lib/python2.7/site-packages/pyqtgraph/__init__.py in <module>()
     11 ## 'Qt' is a local module; it is intended mainly to cover up the differences
     12 ## between PyQt4 and PySide.
---> 13 from .Qt import QtGui
     14
     15 ## not really safe--If we accidentally create another QApplication, the process hangs (and it is very difficult to trace the cause)

/usr/local/lib/python2.7/site-packages/pyqtgraph/Qt.py in <module>()
     42
     43 if QT_LIB is None:
---> 44     raise Exception("PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.")
     45
     46 if QT_LIB == PYSIDE:

Exception: PyQtGraph requires one of PyQt4, PyQt5 or PySide; none of these packages could be imported.

And when I try to import any of the PySide, PyQt4, or PyQt5 packages:

In [7]: import PyQt4
-----------------------------------------------------------
ImportError               Traceback (most recent call last)
<ipython-input-7-0c3b8c686717> in <module>()
----> 1 import PyQt4

ImportError: No module named PyQt4
gsamerica
  • 153
  • 1
  • 3
  • 18
  • Are you sure you installed PyQt5 via Homebrew for the same version of Python that throws the errors? I think the default for PyQt5 is to install for Python3, not 2.7. You can do the latter with the `--with-python` flag to `brew install pyqt5`. – bnaecker Jan 20 '17 at 04:29
  • Do you mean something like `brew install PyQt5 --with-python2.7`? Or is that not correct? I attempted the above and received the warning `Warning: pyqt5-5.7.1 already installed` – gsamerica Jan 20 '17 at 20:59
  • You'll need to do `brew reinstall`, or `brew rm` then `brew install` to fix that error. I believe the syntax for the Python 2.7 flag is just `--with-python`, but you can run `brew info pyqt5` to verify. That will list the installation options that are available to any Homebrew formula. So the full command (after you've uninstalled it) is `brew install pyqt5 --with-python`. – bnaecker Jan 20 '17 at 23:48
  • @bnaecker I did what you described here, and after running `easy_install` for another package (pyopengl) it runs. Thanks very much for your help! – gsamerica Feb 11 '17 at 22:43

0 Answers0