I'm trying to install Fabric in Virtualenv but I'm getting an error. I'm usinh Python 2.7.2+
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/andre/python_virtualenv/bin/python -c "import setuptools;__file__='/home/andre/python_virtualenv/build/pycrypto/setup.py'; exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-YGuAIj-record/install-record.txt --install-headers /home/andre/python_virtualenv/include/site/python2.7 failed with error code 1
Storing complete log in /home/andre/.pip/pip.log
Some clues on what's wrong here?
Best Regards,
If you use Debian-flavored Linux, you need to install python2.x-dev package
sudo apt-get install python2.7-dev
This is because some python libs are just binding to C libs which need to be compiled before used, requiring headers to do so.
Fabric use Paramiko to connect via SSH, which includes such bindings.
Headers are often in packages called packagename-dev (debian) or packagename-develop (redhat). Here we see the python.h header is missing for python 2.7, so we install python2.7-dev. You'll have to do that only once for all your wirtual envs since it's installed at the system level.
The same issue appears if you use libs that relate to other C product such as mysql libs, which will require mysql headers.
You need let gcc knows the Python's include path and lib path.
First you need to find your Python's include & lib path.
For example:
/home/me/soft/include
and
/home/me/soft/lib
Then, export the following var in bash
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/home/me/soft/include
And
export LD_LIBRARY_PATH=$C_INCLUDE_PATH:/home/me/soft/lib
This is not the only way, but should be work for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With