• Register
0 votes
1.4k views

Problem :

The import matplotlib.pyplot as plt is is giving me the error with python2.7, anaconda3.

The error shown is as below:

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

The Detailed Error report is as below :

Traceback (most recent call last): 
File "<string>", line 1, in <module> 
File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/pyplot.py", line 124, in <module>_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 42, in pylab_setup globals(),locals(),[backend_name],0) File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 18, in <module> from .backend_qt5 import QtCore File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 36, in <module> import matplotlib.backends.qt_editor.figureoptions as figureoptions File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 30, in <module>
import matplotlib.backends.qt_editor.formlayout as formlayout 
File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 70, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore 
File "/serving/anaconda3/envs/python27/lib/python2.7/site-packages/matplotlib/backends/qt_compat.py", line 154, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
6 5 3
7,540 points

1 Answer

0 votes

Solution :

I tried below approach and that worked for me :

import matplotlib 
matplotlib.use("Agg") 
import matplotlib.pyplot as plt

This really worked for me

OR

Please remove below line of code :

import matplotlib.pyplot as plt

 

Please add below line of code :

import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

The main reason behind such a behavior is that if you are running it on the servers witch do not have the gui support or non interactive mode. And if you try to run same code on the jupyter notebook, it will work fine.

9 7 4
38,600 points

Related questions

0 votes
1 answer 1.2K views
1.2K views
Problem : I am facing following error : ImportError: libcuda.so.1: cannot open shared object file: No such file or directory Failed to load the native TensorFlow runtime. Above error comes up when I tried to import the tensorflow. Is there anybody who has faced this error before and know the solution on it?
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 630 views
630 views
Problem : While trying to import the OpenCV, using import cv2 I facing the below error: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>() 12 13 # make IDE's (PyCharm) autocompletion happy ----> 14 from .cv2 import * 15 16 # wildcard import ... - I am trying to play around with the Google's new Colaboratory tool. Please let me know if someone have solution for the above issue.
asked Dec 18, 2019 alecxe 7.5k points
0 votes
1 answer 65 views
65 views
Problem : I am very new to tensorflow-gpu, I want to use the tensorflow-gpu on my system. I have already tried to reinstall tensorflow-gpu many times but still it shows me the following error.If I use the tensorflow-cpu then it works correctly. Please Note: I ... ) ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory Can somebody help me in fixing above error ?
asked Feb 19 mphil 2.3k points
0 votes
2 answers 65 views
65 views
Problem : I have recently installed the cuda 8.0 and cuda 9.0 in the Gpu support system. I encountered the below error while importing from the keras module. It says it is unable to load the native tensorflow runtime. I have received the error log as below: Traceback ... is, Cuda compilation tools, release 8.0, V8.0.61 Is it the clash between two cuda versions? Have anyone solved this before?
asked Feb 18 mphil 2.3k points
0 votes
1 answer 185 views
185 views
Problem : I am building the TensorFlow from the source code. The build appears to succeed; but, when my TensorFlow program invokes the import tensorflow, one or both of the following errors starts appearing: · ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory · ImportError: libcudnn.5: cannot open shared object file: No such file or directory
asked Dec 9, 2019 alecxe 7.5k points