Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Getting matplotlib to work with Python3 on Xubuntu 12.04
Getting matplotlib running with python3
Here are the steps that I went through to get Matplotlib to work.
(as far as I know so far.....)
I am using a Xubuntu 12.04 (Ubuntu) system.
(Your mileage may vary....)
Much thanks to:
Shawn Brown (Google+) :
Allen Barker (Google+) :
sudo apt-get build-dep python-matplotlib
sudo apt-get install python3-dev
unzip master
cd matplotlib-matplotlib-bb3ea55 <=== the directory name will vary with version
sudo python3 build
sudo python3 install
sudo apt-get install python3-pyqt4
HEY! It works.....
mlongval _at_ gmail _dot_ com

This comment has been minimized.

Copy link

@lethalfang lethalfang commented Apr 4, 2013

I've gotten those things to work before, but unfortunately I can't get this one to work in Xubuntu 12.04.
When I did sudo python3 build:

lethalfang@TARDIS:~/matplotlib-matplotlib-6be9771$ sudo python3 build

Edit setup.cfg to change the build options

matplotlib: yes [1.3.x]
python: yes [3.2.3 (default, Oct 19 2012, 20:10:41) [GCC
platform: yes [linux2]

numpy: yes [version 1.6.1]
dateutil: yes [using dateutil version 2.1]
tornado: yes [using tornado version 3.0]
pyparsing: yes [using pyparsing version 2.0.0]
pycxx: yes [Official versions of PyCXX are not compatible
with Python 3.x. Using local copy]
libagg: yes [Requires patches that have not been merged
upstream. Using local copy.]
freetype: yes [version 14.0.8]
png: yes [version 1.2.46]

sample_data: yes [installing]
toolkits: yes [installing]
tests: yes [using nose version 1.2.1]

macosx: no [Mac OS-X only]
qt4agg: yes [Qt: 4.8.1, PyQt4: 4.9.1]
gtk3agg: no [Requires pygobject to be installed.]
gtk3cairo: no [Requires pygobject to be installed.]
gtkagg: no [Requires pygtk]
tkagg: yes [version version not identified]
wxagg: no [requires wxPython]
gtk: no [Requires pygtk]
qtagg: no [not found]
agg: yes [installing]
cairo: yes [version 1.10.0]

dvipng: yes [version 1.14]
ghostscript: yes [version 9.05]
latex: yes [version 3.1415926]
pdftops: yes [version 0.18.4]

running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-3.2/matplotlib/mpl-data
running build_ext

Then sudo python3 install
I see a bunch of things like:SyntaxError: invalid syntax

File "/usr/local/lib/python3.2/dist-packages/matplotlib-1.3.x-py3.2-linux-x86_64.egg/matplotlib/backends/", line 384
s = s.replace(u'\u2212', '-').encode('iso-8859-1')
SyntaxError: invalid syntax

File "/usr/local/lib/python3.2/dist-packages/matplotlib-1.3.x-py3.2-linux-x86_64.egg/matplotlib/backends/qt4_editor/", line 53
raise ImportError, "Warning: formlayout requires PyQt4 >v4.3 or PySide"
SyntaxError: invalid syntax

matplotlib 1.3.x is already the active version in easy-install.pth

If I get into python3, and I do "import matplotlib"

In [1]: import matplotlib

RuntimeError Traceback (most recent call last)
/home/lethalfang/matplotlib-matplotlib-6be9771/ in ()
----> 1 import matplotlib

/usr/local/lib/python3.2/dist-packages/matplotlib-1.3.x-py3.2-linux-x86_64.egg/matplotlib/ in ()
--> 180 from matplotlib.rcsetup import (defaultParams,
181 validate_backend,
182 validate_toolbar)

/usr/local/lib/python3.2/dist-packages/matplotlib-1.3.x-py3.2-linux-x86_64.egg/matplotlib/ in ()
19 import warnings
20 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
---> 21 from matplotlib.colors import is_color_like
23 #interactive_bk = ['gtk', 'gtkagg', 'gtkcairo', 'fltkagg', 'qtagg', 'qt4agg',

/usr/local/lib/python3.2/dist-packages/matplotlib-1.3.x-py3.2-linux-x86_64.egg/matplotlib/ in ()
203 # add british equivs

--> 204 for k, v in cnames.items():
205 if k.find('gray') >= 0:
206 k = k.replace('gray', 'grey')

RuntimeError: dictionary changed size during iteration

Any ideas? I'm banging my heads here........


This comment has been minimized.

Copy link

@horvatha horvatha commented Sep 7, 2013

You do not need sudo here:
sudo python3 build
just for install.

It worked fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.