Anaconda on the Raspberry Pi

As most of you probably already know, the PSF gave a Raspberry Pi to everyone attending PyCon 2013 in Santa Clara last weekend. I would like to take the opportunity to thank everyone involved for putting together the most fantastic PyCon ever. I’m always amazed to see this conference exceeding its own standards. After getting home from the conference, I started playing with the Raspberry Pi I got. Setting things up was easy. The Raspberry Pi comes with a 4GB SD card which contains the Debian Linux OS. Because I wanted more external memory, I connected an external hard drive. Being a long term Emacs user, I installed zile (using apt-get), which is a lightweight Emacs clone. Next, I wanted git, which I could not install using apt-get, so I build it from source, which took about one hour.

Having set up a working environment, I ported our internal Anaconda build system to the new device. Basically all I needed to do was to ensure the platform is recognized and that the conda package meta-data is good. The main limiting factor for building packages was speed, e.g. it takes one whole hour to build Python, as supposed to a few minutes on a regular machine. An idea would be to cross compile, but not having done it in the past, I decided not to go that route. Instead, I wrote a little program, which simply tries to build every package in Anaconda and run it in the background. Here is what we’ve got so far:

bitarray, boto, bsdiff4, conda, curl, cython, dateutil, distribute,
docutils, flask, gdata, gevent, gevent-websocket, gevent_zeromq,
googlecl, greenlet, grin, imaging (PIL), ipython, jinja2, libevent,
libpng, libtiff, networkx, nose, ply, psutil, pycparser, pycrypto,
pycurl, pyflakes, pygments, pyparsing, pytest, python (2.7), pytz,
pyyaml, pyzmq, six, sphinx, sqlalchemy, sympy, tornado, werkzeug,
yaml, zeromq


As the conda install tool is platform agnostic, all that was required was adding two lines to the function which returns the name of the platform specific sub-directory from which packages are fetched.

Try Anaconda on your Raspberry Pi

Because only a small subset of the Anaconda packages are available for the Raspberry Pi, we made a “mini Anaconda” (Miniconda) installer which gets you Python and conda, and then allows installing additional packages using the conda command. You can download the installer using this link:  Miniconda-3.5.5-Linux-armv6l.sh

As usual, you can use the following command to install:

$wget http://repo.continuum.io/miniconda/Miniconda-3.5.5-Linux-armv6l.sh$ md5sum Miniconda-3.5.5-Linux-armv6l.sh
2f37cb775ec3e482280a7bd6b97ee501
$/bin/bash Miniconda-3.5.5-Linux-armv6l.sh  Once you installed it and adjusted the PATH environment variable, you can install additional packages using conda, but first lets check what is available: $ conda search
48 matches found compatible with environment /home/pi/anaconda:

Packages with available versions and build strings:

bitarray                  0.8.0                    py27_0
bsdiff4                   1.1.3                    py27_0
conda                     1.5.0                    py27_0
cubes                     0.10.2                   py27_0
cython                    0.18                     py27_0
distribute                0.6.34                   py27_1
docutils                  0.10                     py27_0
...


So install, e.g. bitarray:

$conda install bitarray ...$ python
Python 2.7.3 |Continuum Analytics, Inc.| (default, Mar 21 2013, 01:11:54)
[GCC 4.6.3] on linux2
>>> import bitarray
>>> bitarray.test()
installed in: /home/pi/anaconda/lib/python2.7/site-packages/bitarray
bitarray version: 0.8.0
2.7.3 |Continuum Analytics, Inc.| (default, Mar 21 2013, 01:11:54)
[GCC 4.6.3]
......................................................................
...........................................................
----------------------------------------------------------------------
Ran 129 tests in 56.350s

OK
<unittest.runner.TextTestResult run=129 errors=0 failures=0>
>>>


Running the bitarray unittest on a regular machine only takes about a second or two.

Summary

The Raspberry Pi is a neat little machine, which is easy to get started with. However, because it does not have the computational muscle of a traditional workstation, the pain of building and maintaining packages (especially those with C extensions) is amplified.

Continuum Analytics has built a number of binary packages for the Raspberry Pi. By using conda, Python coders can try out different versions of libraries and have very robust virtual environments. Additionally, because the conda package management tool is written in pure Python and therefore platform agnostic, it already supports Raspberry Pi out of the box.

Are there packages you’d like to be able to easily install and use on Raspberry Pi? Let us know! Join the Anaconda mailing list or email us at info@continuum.io!

Tags: Raspberry Pi ARM11 Anaconda conda