I wrote a post a little while ago raving about the benefits of using Perlbrew to manage your perl installation and, crucially, allow you to install additional modules without the need of administer access to the machine.
Well, the Perlbrew project inspired a group of people to work on Pythonbrew, which is broadly similar but for python. It comes with pip, a really easy to use installer module that allows you to grab packages from PyPI (Python Package Index). Naturally, it working well on my system (Ubuntu 12.04) led me to recommend it to some of my colleagues for working with Python. And, naturally, it had issues. And, just to make things even more frustrating, the machine that they were using runs on an old version of CentOS (5.8) with what feels like nothing installed. Oh, and they didn’t have administrator privileges, so I couldn’t install anything without configuring it all for their home directory! URGH
Some modules, like matplotlib installed really quickly and cleanly:
$pip install matplotlib ... Successfully installed matplotlib Cleaning up...
The real issues came with ‘pip install numpy’ (and scipy), which seemed to fail on patching together some C libraries, with an end result:
Command /home/USER/.pythonbrew/pythons/Python-2.7.2/bin/python -c "import setuptools;__file__='/home/USER/build/numpy/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-2RdvJ1-record/install-record.txt failed with error code 1 in /home/USER/build/numpy Storing complete log in /home/USER/.pip/pip.log
Short to say that the compiler “Failed with exit status 1′. On the machine that I was working on, this was a major pain in the arse. Plus, I had no way of knowing if it was merely that the version of libc was old or that I hadn’t included the correct library path. However, someone on a message forum suggested that I use the ‘bleeding edge’ github version of numpy as the issue might have been fixed. Low and behold:
$pip install git+git://github.com/numpy/numpy.git ... Successfully installed numpy Cleaning up...
$pip install git+git://github.com/scipy/scipy.git ... Successfully installed scipy Cleaning up...
Naice. I wouldn’t make a habit of using the github version of a project, but if you’re finding that you’re having issues with installing from PyPI then maybe give it a go!
Finally, MySQLdb also played up on the system that I was working on (again because of C libraries not linking). However, I came across PyMySQL, which is a pure python implementation of a MySQL interface, which is designed to be a ‘drop-in’ replacement to MySQLdb. As the project git wiki states:
“MySQLdb, is a C extension module that has a reputation of being difficult to compile, especially if you’re on a Mac. Additionally, end-users need to wait for new binaries to be compiled for each new release of Python [...]“
“It [PyMySQL] is also a drop-in replacement for the standard way of connecting to MySQL in Python, MySQLdb. Just import pymysql; pymysql.install_as_MySQLdb() in any existing project before MySQLdb is imported, and it’ll work.”
As it’s pure python, you’re already having issues with C linker libraries then perhaps try something written in pure python. ‘pip install pymysql’ installed it nicely on the ‘problem’ system nicely.