可以在Virtualenv中安装Fabric(Python)吗?得到一个错误

And*_*dré 7 python virtualenv fabric

我正在尝试在Virtualenv中安装Fabric,但是我收到了一个错误.我是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
Run Code Online (Sandbox Code Playgroud)

这里有什么错误的线索?

最好的祝福,

vor*_*hin 15

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

sudo apt-get install python2.7-dev

这是因为一些python库只是绑定到C libs,需要在使用之前进行编译,这需要头文件这样做.

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

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

如果您使用与其他C产品(例如mysql库)相关的库,则会出现同样的问题,这将需要mysql头.