Amazon Linux EC2实例上的uWSGI安装例外

时间:2014-09-26 19:20:52

标签: django nginx amazon-ec2 uwsgi

我是一个新手,尝试使用nginx,django,uWSGI和mySQL在Amazon EC2上为我的第一个手机应用程序设置服务器。

我正在关注这些教程(实际上第二篇是基于第一篇):

http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html http://www.oliverelliott.org/article/computing/tut_setup_nginx_django/

我正在使用MacbookPro,并且在终端中我将进入Amazon Linux EC2实例。 当谈到安装uwsgi..troubles出现。 我执行了:

$ sudo yum install python-pip
$ sudo yum install python-devel
$ sudo pip install uwsgi

前两个工作正常,最后一个命令抛出异常:

    Downloading/unpacking uwsgi
  Running setup.py egg_info for package uwsgi
Installing collected packages: uwsgi
  Running setup.py install for uwsgi
    using profile: buildconf/default.ini
    detected include path: ['/usr/include', '/usr/local/include']
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-root/uwsgi/setup.py", line 109, in <module>
        distclass=uWSGIDistribution,
      File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
        self.run_command(cmd)
      File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-root/uwsgi/setup.py", line 71, in run
        conf = uc.uConf(get_profile())
      File "uwsgiconfig.py", line 687, in __init__
        raise Exception("you need a C compiler to build uWSGI")
    Exception: you need a C compiler to build uWSGI
    Complete output from command /usr/bin/python26 -c "import setuptools;__file__='/tmp/pip-build-root/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-l8npX4-record/install-record.txt --single-version-externally-managed:
    running install

using profile: buildconf/default.ini

detected include path: ['/usr/include', '/usr/local/include']

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/tmp/pip-build-root/uwsgi/setup.py", line 109, in <module>

    distclass=uWSGIDistribution,

  File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup

    dist.run_commands()

  File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands

    self.run_command(cmd)

  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command

    cmd_obj.run()

  File "/tmp/pip-build-root/uwsgi/setup.py", line 71, in run

    conf = uc.uConf(get_profile())

  File "uwsgiconfig.py", line 687, in __init__

    raise Exception("you need a C compiler to build uWSGI")

Exception: you need a C compiler to build uWSGI

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

我已经尝试了两个我读过的建议,但似乎对我不起作用:

$ export CC=gcc && pip install -r requirements.txt 

$ sudo CC=gcc pip install uwsgi

有什么建议吗?非常感谢提前!!

2 个答案:

答案 0 :(得分:10)

此链接帮助了我:uWSGI: Installing from a distribution package

我做了:

yum groupinstall "Development Tools"
yum install python-devel

然后:

pip install uwsgi

之后就可以了。

答案 1 :(得分:0)

我已经解决了在我的EC2实例(Ubuntu 18.04)上安装gcc的问题:

sudo apt install gcc

然后:

pip install uwsgi

为我工作。

希望有帮助。