Reputation: 36
Today when I used the command "import matplotlib.pyplot" in ipython,it showd the problem like that: `
`In [6]: import matplotlib.pyplot
ImportError Traceback (most recent call last) in () ----> 1 import matplotlib.pyplot
/root/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py in () 113 114 from matplotlib.backends import pylab_setup --> 115 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() 116 117 _IP_REGISTERED = None
/root/anaconda2/lib/python2.7/site-packages/matplotlib/backends/init.pyc 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
/root/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py in () 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
/root/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py in () 24 25 from matplotlib.widgets import SubplotTool ---> 26 import matplotlib.backends.qt_editor.figureoptions as figureoptions 27 28 from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName,
/root/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_editor/figureoptions.py in () 18 import matplotlib 19 from matplotlib import cm, markers, colors as mcolors ---> 20 import matplotlib.backends.qt_editor.formlayout as formlayout 21 from matplotlib.backends.qt_compat import QtGui 22
/root/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_editor/formlayout.py in () 54 55 from matplotlib import colors as mcolors ---> 56 from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore 57 58
/root/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_compat.py in () 126 if QT_API == QT_API_PYQT5: 127 try: --> 128 from PyQt5 import QtCore, QtGui, QtWidgets 129 _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName 130 except ImportError:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
my python version is
Python 2.7.13 :: Anaconda 4.4.0 (64-bit)
my os is
CentOS release 6.8 (Final)
Kernel \r on an \m
I don't know how to deal with this problem thanks
Upvotes: 2
Views: 2787
Reputation: 6122
As discussed here, This solved the issue for me : https://github.com/matplotlib/matplotlib/issues/9954
import matplotlib
matplotlib.use("tkagg")
import matplotlib.pyplot as plt
Upvotes: 1
Reputation: 1319
Installing mesa libgl worked for me in case the env is ubuntu 16
sudo apt install libgl1-mesa-glx
Upvotes: 3
Reputation: 3172
I experienced this problem as well with conda. What I ended up doing is as follow
#activate the environment
source activate myenv
#use pip instead of conda install
pip install matplotlib
Upvotes: 0