Sunday, May 13, 2012

Troubleshooting python packages installation

This post lists some of the problems encountered while trying to set up development environment for kuma, a Python (django-) based wiki engine.

I'm using Mac OS X 10.7, Macports as the package manager.

A note about virtualenv

virtualenv lets you install python packages for a particular project into an isolated environment.

When relying on macports to install dependencies, it's a good idea to use Python provided by Macports, otherwise the system might not see some of the dependencies you installed with Macports.

Using virtualenvwrapper, you can specify the python binary to use when creating the environment like this:

#assuming python2.7 is a macports binary (typically in /opt/local/bin)
mkvirtualenv kuma-test-py2.7 -p python2.7

Problems and solutions

Error installing MySQL-python: EnvironmentError: mysql_config not found

Via http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found: you need to edit site.cfg to point to the right mysql_config path.

In my case (with virualenv and macports mysql), I ended up modifying /Users/nickolay/.virtualenvs/<environment-name>/build/MySQL-python/site.cfg to point to /opt/local/bin/mysql_config5).

Errors involving pylibmc and memcached

_pylibmcmodule.h:42:36: error: libmemcached/memcached.h: No such file or directory

First make sure you installed libmemcached, e.g. using Macports:

sudo port install libmemcached

For some reason on my system I also needed to explicitly set the path to headers before retrying pylibmc installation:

export CPATH=/opt/local/include/

ld: library not found for -lmemcached, collect2: ld returned 1 exit status

This happened for me when trying to install into a virtualenv using system python, not macports one. (See the section on virtualenv above.)

ImportError: failed to find libmagic.  Check your installation

To install libmagic in Macports, use:

port install file

1 comment:

  1. Excellent post. The CPATH export it's what I was missing installing libmemcached via brew.
    After that line, pip installed pylibmc like a charm :)
    Thanks!

    ReplyDelete