Setup:
Processor : x86_64
Operating System: GNU/Linux
Distro: Fedora Release 13 (Goddard).
Python 2.6.4
/usr/bin/python
Here is the following issue:
I am trying to generate a few graphs using Matplotlib and Python. As I hear from a majority of the solutions3.. there seem to be compatibility issues between matplotlib and 64bit architectures.
I have installed Matplotlib from here
Here is the error that I get:
Traceback (most recent call last): File "plot-thread-characterization.py", line 24, in <module> import matplotlib.pyplot as plt File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module> new_figure_manager, draw_if_interactive, show = pylab_setup() File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup globals(),locals(),[backend_name]) File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module> from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\ File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module> import gtk; gdk = gtk.gdk File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module> _init() File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init _gtk.init_check() RuntimeError: could not open display
Thanks.
Matplotlib is not a built-in module (it doesn't come with the default python installation) in Python, you need to install it explicitly using the pip installer and then use it. If you looking at how to install pip or if you are getting an error installing pip checkout pip: command not found to resolve the issue.
BUILDING MATPLOTLIB matplotlib: yes [3.3. 2] python: yes [3.9.
The most frequent source of this error is that you haven't installed matplotlib explicitly with pip install matplotlib . Alternatively, you may have different Python versions on your computer, and matplotlib is not installed for the particular version you're using.
The Python "ModuleNotFoundError: No module named 'matplotlib'" occurs when we forget to install the matplotlib module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install matplotlib command.
matplotlib is failing to connect to any X server for its GTK display.
There are a couple of options here:
Run a local X server and enable X11 forwarding in your ssh client, to display the output on your local machine. You can verify this is working by checking that the $DISPLAY environment variable is set on the server.
Call matplotlib.use(...) to specify a different display back-end, for example rendering to pdf file, before importing pyplot, e.g.
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
See http://matplotlib.org/faq/howto_faq.html#generate-images-without-having-a-window-appear for more details.
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