2012-01-06 36 views
7

我试图在Virtualenv中安装Fabric,但出现错误。我是usinh Python 2.7.2+可以在Virtualenv中安装Fabric(Python)吗?获取错误

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 

这里有什么问题的一些线索?

最好的问候,

回答

15

如果使用Debian的Linux的味,您需要安装python2.x-dev软件包

命令和apt-get安装python2.7-dev的

这是因为一些Python库只是结合需要在使用之前编译的C库,需要头文件来完成。

Fabric使用Paramiko通过SSH连接,其中包含此类绑定。

头文件通常位于packagename-dev(debian)或packagename-develop(redhat)的包中。在这里,我们看到Python 2.7的python.h头文件缺失,所以我们安装python2.7-dev。因为它是在系统级别安装的,所以对于所有的虚拟环境,您只需要执行一次该操作。

如果您使用与其他C产品相关的库(例如mysql libs,它需要mysql头文件),则会出现相同的问题。

+1

@ e-satis非常感谢你为这个伟大的加法! – vorushin 2012-01-06 14:26:02

+1

你在我做之前就回答了它,所以没有用的做一个重复的:-) – 2012-01-06 16:28:43

1

你需要让GCC知道Python的include路径和lib路径。

首先你需要找到你的Python的包含&的lib路径。

例如:

/home/me/soft/include 

/home/me/soft/lib 

然后导出以下VAR在bash

export C_INCLUDE_PATH=$C_INCLUDE_PATH:/home/me/soft/include 

而且

export LD_LIBRARY_PATH=$C_INCLUDE_PATH:/home/me/soft/lib 

这不是唯一的方法,但应该为你工作。

相关问题