Wednesday, June 19, 2013

matplotlib followup for Python 3 on OS X 10.8

In my last post, I reported success in installing matplotlib on OS X. I realize now that this is not anything new to report, since the currently recommended install process (which I read belatedly today) in the README is to use Homebrew (or MacPorts), which is what I did. I'm just happy to know that it works.

I thought I'd say a word about Python 3 here.

I did

$ brew install python3 --framework

which first installed readline and sqlite (linked into /usr/local/opt), as well as gdbm and xz, and also Distribute and pip.

So now we have:

$ ls /usr/local/lib/python3.3/site-packages/
__pycache__    setuptools-0.6c11-py3.3.egg-info
distribute-0.6.45-py3.3.egg  setuptools.pth

$ python3
Python 3.3.2 (default, Jun 19 2013, 15:41:32) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import autotest
== CPython 3.3.2 (default, Jun 19 2013, 15:41:32) [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]
==   Darwin-12.4.0-x86_64-i386-64bit little-endian
==   /usr/local/bin
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)
[  1/372] test_grammar
[  2/372] test_opcodes
[  3/372] test_dict
[  4/372] test_builtin

The tests hang at this point, and I haven't figured out why yet. They do fine with my system Python. Then I did:

$ pip3 install numpy
$ pip3 install nose

since we need numpy for matplotlib (and don't get it for free as with System Python).

Following this advice, I did:

$ python3
>>> import numpy
>>> numpy.test('full')

Ran 4808 tests in 64.611s

<nose.result.TextTestResult run=4808 errors=0 failures=0>

Now to matplotlib

$ git clone git://
$ cd matplotlib
$ python3 build
$ sudo python3 install

(Grabs pyparsing, dateutil, tornado).

$ cd..
$ python3
>>> import matplotlib.pyplot as plt
>>> Y = [1,4,9,16]
>>> plt.scatter(range(len(Y)),Y,s=250,color='r')
<matplotlib.collections.PathCollection object at 0x1094e4650>
>>> plt.savefig('example.png')


$ pip3 install cython

had a permissions problem, so I did

$ sudo chmod -R 755 /usr/local/lib/python3.3/site-packages/
$ pip3 install cython

Now, for scipy

$ git clone git:// scipy
$ cd scipy
$ python3 build
$ sudo python3 install

$ cd ..
$ python3
>>> from scipy.stats import norm
>>> norm.cdf(2)

>>> import scipy
>>> scipy.test('full')

Ran 7486 tests in 725.812s

FAILED (KNOWNFAIL=42, SKIP=296, failures=82)

Some failures, but all in all it looks good, and a very easy install.

No comments: