matplotlib - gher-uliege/Documentation GitHub Wiki

matplotlib

Matlabplot is a very flexible graphics library, but unfortortunately it can be sometimes difficult to get a backend to work on a machine without root access.

$ python3
Python 3.4.5 (default, May 29 2017, 15:17:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/abarth/.local/lib/python3.4/site-packages/matplotlib/pyplot.py", line 113, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/abarth/.local/lib/python3.4/site-packages/matplotlib/backends/__init__.py", line 60, in pylab_setup
    [backend_name], 0)
  File "/home/abarth/.local/lib/python3.4/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
    from six.moves import tkinter as Tk
  File "/home/abarth/.local/lib/python3.4/site-packages/six.py", line 92, in __get__
    result = self._resolve()
  File "/home/abarth/.local/lib/python3.4/site-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/home/abarth/.local/lib/python3.4/site-packages/six.py", line 82, in _import_module
    __import__(name)
ImportError: No module named 'tkinter'
>>> 

TK

With root privileges:

sudo yum install python34-tkinter

Without root: ?

* PyQT4/5


To change the backend:
```bash
cat <<EOF >> ~/.config/matplotlib/matplotlibrc
backend : Qt4Agg
EOF

Unfortunatetly, PyQT4/5 cannot be installed from pip https://github.com/pypa/pip/issues/2157

  • PyGTK
$ pip3 install --user 'PyGTK'
Collecting PyGTK
  Downloading pygtk-2.24.0.tar.bz2 (2.4MB)
    100% |████████████████████████████████| 2.4MB 251kB/s 
    Complete output from command python setup.py egg_info:
    ********************************************************************
    * Building PyGTK using distutils is only supported on windows. *
    * To build PyGTK in a supported way, read the INSTALL file.    *
    ********************************************************************

Possible solution: https://stackoverflow.com/questions/9064289/installing-pygtk-in-virtualenv

⚠️ **GitHub.com Fallback** ⚠️