We love python virtual environments, but under FreeBSD we occasionally see issues where pip is not correctly using the /usr/local/include and /usr/local/lib paths to compile installable modules.

The Problem

This can produce errors such as the below, which we saw when doing a ‘pip install pycrypto’ operation:

src/_fastmath.c:36:11: fatal error: 'gmp.h' file not found

Even though gmp is installed, it’s not finding the header files due to pip not looking in the right locations for FreeBSD (which is /usr/local )

The Solution

The easiest and most effective solution is to export CFLAGS into the environment via the following:

env "CFLAGS=-I/usr/local/include -L/usr/local/lib" pip install pycrypto

(again using ‘pip install pycrpyto’ as an example).

Viola!

One Response to “SOLVED: FreeBSD + pip + virtualenv = file not found”

Leave a Reply

Your email address will not be published. Required fields are marked *