Skip to content

Instantly share code, notes, and snippets.

@mlongval
Created February 14, 2013 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlongval/4950532 to your computer and use it in GitHub Desktop.
Save mlongval/4950532 to your computer and use it in GitHub Desktop.
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+) : https://plus.google.com/115875830338788300419
Allen Barker (Google+) : https://plus.google.com/106118888722552311940
sudo apt-get build-dep python-matplotlib
sudo apt-get install python3-dev
wget https://github.com/matplotlib/matplotlib/zipball/master
unzip master
cd matplotlib-matplotlib-bb3ea55 <=== the directory name will vary with version
sudo python3 setup.py build
sudo python3 setup.py install
sudo apt-get install python3-pyqt4
HEY! It works.....
Mike
mlongval _at_ gmail _dot_ com
@lethalfang
Copy link

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 setup.py build:

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

Edit setup.cfg to change the build options

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

REQUIRED DEPENDENCIES AND EXTENSIONS
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]

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

OPTIONAL BACKEND EXTENSIONS
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]

OPTIONAL LATEX DEPENDENCIES
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 setup.py 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/backend_emf.py", 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/formlayout.py", 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/init.py in ()
178
179
--> 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/rcsetup.py in ()
19 import warnings
20 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
---> 21 from matplotlib.colors import is_color_like
22
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/colors.py in ()
202
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........

@horvatha
Copy link

horvatha commented Sep 7, 2013

You do not need sudo here:
sudo python3 setup.py 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