I am trying to use pyqtgraph in PyDev. I can display a plot window within an application using:
import pyqtgraph as pg
However when I try to embed a widget inside a PyQt application using:
from pyqtgraph import PlotWidget
I get a ImportError: cannot import name 'PlotWidget'
I am using a virtualenv with python3 and pyqtgraph installed in the site-packages. The python interpreted libraries includes the python3 site-packages where pyqtgraph is located.
The exact same code I am trying in PyDev works fine in PyCharm using the same virtualenv.
I added the text pyqtgraph to window-preferences-PyDev-Interpreters-Forced Builtins.
I tried 'Force restore internal info' button on the PyDev-PYTHONPATH settings dialog.
I also tried on project RMB-PyDev-Remove Project Config. The made into PyDev project again, File-Restart, Close project, Open Project.
And I tried adding the site-packages/pyqtgraph folder to the External Libraries in the PYTHONPATH.
In addition I then added to the code:
import sys
sys.path.append("/work/.virtualenvs/python3virt/lib/python3.4/site-packages/pyqtgraph")
before the import block shown below. I can see that /work/.virtualenvs/python3virt/lib/python3.4/site-packages/pyqtgraph is clearly on the system path, but get the error ImportError: No module named 'pyqtgraph.widgets'
Curiously sometimes hitting F3 while hovering over pyqtgraph in the import statements will go to the source, other times it wont. For example in the following code, F3 works on the second pyqtgraph import only:
import pyqtgraph as pg
try:
from pyqtgraph import PlotWidget
except ImportError:
import sys
print ('Executable:', sys.executable)
print ('\n'.join(sorted(sys.path)))
raise
Does anyone have any ideas on how to get PyDev to recognize the internals of pyqtgraph?