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!

Call 1-828-376-0458 to Work With Professionals Who Truly Understand FreeBSD

A-Team Systems is a proud supporter of the FreeBSD Foundation and many of our administrators are direct project contributors.

 

2 Responses to “SOLVED: FreeBSD + pip + virtualenv = file not found”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.