Reputation: 812
When I import matplotlib.pyplot
in any python 3.6 program, I get the following error:
$ python kernel1.py
Traceback (most recent call last):
File "kernel1.py", line 13, in <module>
import matplotlib.pyplot as plt
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5agg.py", line 16, in <module>
from .backend_qt5 import QtCore
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 26, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 20, in <module>
import matplotlib.backends.qt_editor.formlayout as formlayout
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 56, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "/home/atul/anaconda3/lib/python3.6/site-packages/matplotlib/backends/qt_compat.py", line 137, in <module>
from PyQt4 import QtCore, QtGui
ModuleNotFoundError: No module named 'PyQt4'
However, if I use python 3.5, matplotlib.pyplot
works perfectly.
I have tried using sudo apt-get install python-qt4
. Still I get the same error.
I am using Ubuntu 16.04.
Upvotes: 0
Views: 4480
Reputation: 2988
For python 3.6(since i had that in my computer), you go to command line , and type this :
conda install -c anaconda pyqt=5.6.0
If you are unsure about the python and pyqt version. Then type :
conda info pyqt
This will output the relevant pyqt version. Hence you can check your pyqt version and install from command mentioned at first.
Upvotes: 1
Reputation: 38
You need to downgrade to PyQt4 from PyQt5 at the command line within the relevant environment:
conda install pyqt=4
This will downgrade other packages as well. You may need to think about using PyQt5 if this will cause you other problems when using Python 3.6.
Also, Continuum do not support this version for Python 3.6+. Please see this GitHub page for confirmation.
Upvotes: 2