Install uwsgi 1.2.5 via pip

Welcome,

Currently I'm trying to install latest uwsgi on my VPS (Ubuntu 11.10) based on instruction from the site http://projects.unbit.it/uwsgi/wiki/Quickstart

pip install uwsgi

During compilation I see some errors:

...
[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
...

And finally I see:

...

[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

Has anyone any suggestions how can I install latest uwsgi?

Regards, Grzegorz


Solution 1:

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

To compile C extensions for Python you need Python development files:

$ sudo apt-get install python2.7-dev

Solution 2:

Just so will be here in case someone else comes across this problem:

Even though we had installed python2.7-dev successfully we still got this error.

What apparently was the problem was gcc's inability to find the libraries which were included in the build script pip was trying to run.

We actually ended up getting the uwsgi pip zip:

  • https://pypi.python.org/packages/source/u/uWSGI/uwsgi-1.9.20.tar.gz

and then changing it manually like with the following steps.

First, we unzipped it:

tar xvzf uwsgi-1.9.20.tar.gz

Then, we edited the file uwsgiconfig.py, replacing line 213,

cmdline = "%s -c %s -o %s %s" % (GCC, cflags, objfile, srcfile)

To say this instead:

cmdline = "%s -I/usr/include/libxml2 -c %s -o %s %s" % (GCC, cflags, objfile, srcfile)

Basically, letting gcc know that your libraries are at /usr/include/libxml2 (this was our case at least).

After that, we rezipped the folder:

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

And used pip with that gzip file:

sudo pip install uwsgi-1.9.20.tar.gz

And that worked. Hope that helps someone!