编译失败,错误代码为/ tmp/pip_build_root/uwsgi

use*_*629 2 python ubuntu uwsgi

我正在尝试按照http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html上的教程进行操作.我已经把所有工作都归结为:http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html#install-uwsgi-system-wide.我正在亚马逊EC2上使用ubuntu 14.4实例:

没有进入我的virtualenv,我跑了:

sudo pip install uwsgi 
Run Code Online (Sandbox Code Playgroud)

这导致:

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/uwsgi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-64P2dl-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/uwsgi
Storing debug log for failure in /home/ubuntu/.pip/pip.log
Run Code Online (Sandbox Code Playgroud)

日志有:

Cleaning up...
  Removing temporary dir /tmp/pip_build_ubuntu...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-uLEPHb-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hPh8D0-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-uLEPHb-build
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 706, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python2.7/dist-packages/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-uLEPHb-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hPh8D0-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-uLEPHb-build
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

小智 7

回答你的问题可能有点迟,但是我的回答可以帮助别人.

我向后看着日志,看到了这些线条.

[x86_64-linux-gnu-gcc -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
 #include 
                   ^
compilation terminated.

原来它找不到Python.h.安装python2.7-dev为我解决了这个问题.

apt-get install -y python2.7-dev

  • `apt-get install -y python3-dev`也适用于python3环境 (2认同)