使用pip安装uwsgi 1.2.5

欢迎,
目前我正在尝试根据网站上的指示(http://projects.unbit.it/uwsgi/wiki/Quickstart)在我的VPS(Ubuntu 11.10)上安装最新的uwsgi。
pip install uwsgi

在编译过程中,我看到了一些错误:
...
[gcc -pthread] spooler.o
*** uWSGI compiling embedded plugins ***
[gcc -pthread] plugins/python/python_plugin.o
Complete output from command /usr/bin/python -c "import setuptools;__file__='/etc/apt/sources.list.d/build/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-joud1I-record/install-record.txt:
running install

In file included from plugins/python/python_plugin.c:1:0:

plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory

compilation terminated.

using profile: buildconf/default.ini

detected include path: ['/usr/lib/gcc/i686-linux-gnu/4.6.1/include','/usr/local/include', '/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed', '/usr/include/i386-linux-gnu', '/usr/include']

Patching "bin_name" to properly install_scripts dir
...

最后我看到的是:
...

[gcc -pthread] spooler.o

*** uWSGI compiling embedded plugins ***

[gcc -pthread] plugins/python/python_plugin.o

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/etc/apt/sources.list.d/build/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-joud1I-record/install-record.txt failed with error code 1 in /etc/apt/sources.list.d/build/uwsgi
Storing complete log in /root/.pip/pip.log

有人有什么建议,我如何安装最新的uwsgi吗?
谢谢, Grzegorz

1在按照上述所有建议操作后,结果发现我不应该运行pip3 install uwsgi命令,而是应该以root身份运行:sudo pip3 install uwsgi。 - tomekwi
3个回答

编译Python的C扩展需要安装Python开发文件:
$ sudo apt-get install python2.7-dev

@J.F.Sebastian:请看一下相关的http://askubuntu.com/q/499206/306605。谢谢。 - pepr
@J.F.Sebastian: ... 或者 http://stackoverflow.com/q/24822829/1346705 - pepr
在Debian Wheezy上使用Python 3.4时遇到了同样的错误,这个方法很有帮助,谢谢! - fnkr
我已经安装了python2.7-dev,但仍然看到错误提示。 - yentsun

只是为了防止其他人遇到这个问题,我在这里留下记录:
尽管我们已经成功安装了python2.7-dev,但我们仍然遇到了这个错误。
显然问题出在gcc无法找到构建脚本pip尝试运行的库文件上。
最终我们实际上是通过获取uwsgi pip zip来解决的。 然后像以下步骤一样手动更改它。
首先,我们解压缩它:
tar xvzf uwsgi-1.9.20.tar.gz

然后,我们编辑了文件uwsgiconfig.py,将第213行替换为。
cmdline = "%s -c %s -o %s %s" % (GCC, cflags, objfile, srcfile)

用另一种说法来表达这个意思:
cmdline = "%s -I/usr/include/libxml2 -c %s -o %s %s" % (GCC, cflags, objfile, srcfile)

基本上,让gcc知道你的库位于/usr/include/libxml2(这至少是我们的情况)。

之后,我们重新压缩了文件夹:

tar cvf uwsgi-1.9.20.tar uwsgi-1.9.20/
gzip uwsgi-1.9.20.tar

使用pip命令来处理该gzip文件:
sudo pip install uwsgi-1.9.20.tar.gz

那个方法有效。希望能对某人有所帮助!

如果您的GCC安装无法找到通过标准软件包安装的头文件,则表示您的GCC安装有问题。 - jfs

在Cygwin下通过pip安装,需要以下软件包:
- gcc-core - gcc-g++(可能) - libcrypt-devel - libintl-devel - python3 - python3-devel