I am getting the below error with the following imports. It seems to be related to pandas import. I am unsure how to debug/solve this.
Imports:
import pandas as pd
import numpy as np
import pdb, math, pickle
import matplotlib.pyplot as plt
Error:
In [1]: %run NN.py
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/abhishek/Desktop/submission/a1/new/NN.py in <module>()
2 import numpy as np
3 import pdb, math, pickle
----> 4 import matplotlib.pyplot as plt
5
6 class NN(object):
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/pyplot.py in <module>()
112
113 from matplotlib.backends import pylab_setup
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
115
116 _IP_REGISTERED = None
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/__init__.py in pylab_setup()
30 # imports. 0 means only perform absolute imports.
31 backend_mod = __import__(backend_name,
---> 32 globals(),locals(),[backend_name],0)
33
34 # Things we pull in from all backends
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt4agg.py in <module>()
16
17
---> 18 from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
19
20 from .backend_agg import FigureCanvasAgg
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py in <module>()
14
15 from .backend_agg import FigureCanvasAgg
---> 16 from .backend_qt5 import QtCore
17 from .backend_qt5 import QtGui
18 from .backend_qt5 import FigureManagerQT
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/backend_qt5.py in <module>()
29 figureoptions = None
30
---> 31 from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
32 from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool
33
/home/abhishek/anaconda3/lib/python3.5/site-packages/matplotlib/backends/qt_compat.py in <module>()
135 # have been changed in the above if block
136 if QT_API in [QT_API_PYQT, QT_API_PYQTv2]: # PyQt4 API
--> 137 from PyQt4 import QtCore, QtGui
138
139 try:
ImportError: cannot import name 'QtCore'
Debugging:
$ python -c "import PyQt4"
$ python -c "from PyQt4 import QtCore"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name 'QtCore'
$ conda list | grep qt
jupyter-qtconsole-colorschemes 0.7.1 <pip>
pyqt 5.6.0 py35_0
qt 5.6.0 0
qtawesome 0.3.3 py35_0
qtconsole 4.2.1 py35_0
qtpy 1.0.2 py35_0
I found other answers but all related to Windows. I am using ubuntu 16.04 with anaconda distribution of python 3.
Downgrading pyqt version 5.6.0 to 4.11.4, and qt from version 5.6.0 to 4.8.7 fixes this:
$ conda install pyqt=4.11.4
$ conda install qt=4.8.7
The issue itself is being resolved here: https://github.com/ContinuumIO/anaconda-issues/issues/1068
To avoid downgrading you can also (as was suggested by tacaswell in the issue) set the backend to use Qt5Agg
using one of the methods here: http://matplotlib.org/faq/usage_faq.html#what-is-a-backend
E.g., you can modify the matplotlibrc file located in /your/path/to/anaconda3/envs/yourenv/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
and change the backend line to backend : Qt5Agg
. This will make the Qt5Agg
backend the default throughout the yourenv
conda environment.
Updating matplotlib did the trick for me:
conda install matplotlib
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With