uwsgi的建筑轮子失败

use*_*674 5 python ubuntu uwsgi

我收到一个错误,uwsgi的建筑轮子失败。我的环境是Ubuntu,现在我想安装uwsgi,所以我运行命令 pip install uwsgi。但是发生错误

 Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-9t06jm4_/uwsgi/setup.py", line 126, in <module>
      distclass=uWSGIDistribution,
    File "/home/ubuntu/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/home/ubuntu/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/home/ubuntu/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 215, in run
      self.run_command('install')
    File "/home/ubuntu/anaconda3/lib/python3.5/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/ubuntu/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-9t06jm4_/uwsgi/setup.py", line 77, in run
      conf = uc.uConf(get_profile())
    File "/tmp/pip-build-9t06jm4_/uwsgi/uwsgiconfig.py", line 742, in __init__
      raise Exception("you need a C compiler to build uWSGI")
  Exception: you need a C compiler to build uWSGI

  ----------------------------------------
  Failed building wheel for uwsgi
  Running setup.py clean for uwsgi
Failed to build uwsgi
Installing collected packages: uwsgi
  Running setup.py install for uwsgi ... error
    Complete output from command /home/ubuntu/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9t06jm4_/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-oxbyg6gk-record/install-record.txt --single-version-externally-managed --compile:
    /home/ubuntu/anaconda3/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'descriptions'
      warnings.warn(msg)
    running install
    using profile: buildconf/default.ini
    detected include path: ['/usr/include', '/usr/local/include']
    Traceback (most recent call last):
      File "/tmp/pip-build-9t06jm4_/uwsgi/uwsgiconfig.py", line 734, in __init__
        gcc_version_components = gcc_version.split('.')
    AttributeError: 'NoneType' object has no attribute 'split'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-9t06jm4_/uwsgi/setup.py", line 126, in <module>
        distclass=uWSGIDistribution,
      File "/home/ubuntu/anaconda3/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/ubuntu/anaconda3/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/home/ubuntu/anaconda3/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-9t06jm4_/uwsgi/setup.py", line 77, in run
        conf = uc.uConf(get_profile())
      File "/tmp/pip-build-9t06jm4_/uwsgi/uwsgiconfig.py", line 742, in __init__
        raise Exception("you need a C compiler to build uWSGI")
    Exception: you need a C compiler to build uWSGI

    ----------------------------------------
Command "/home/ubuntu/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9t06jm4_/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-oxbyg6gk-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9t06jm4_/uwsgi/
Run Code Online (Sandbox Code Playgroud)

我运行命令sudo apt-get -y install python-dev,但是发生相同的错误。我真的不明白为什么会发生这些错误。我该如何解决?为什么我告诉我在uWSGI中需要C编译器?我该如何解决这个问题? ?

run*_*g.t 20

您的异常明确说明出了什么问题:

gcc_version_components = gcc_version.split('.')
AttributeError: 'NoneType' object has no attribute 'split'
Run Code Online (Sandbox Code Playgroud)

raise Exception("you need a C compiler to build uWSGI")
Exception: you need a C compiler to build uWSGI
Run Code Online (Sandbox Code Playgroud)

所以一般来说你的系统没有安装c编译器(例如gcc)。尝试安装它。在 Ubuntu 中,它将是sudo apt-get install gcc.

顺便提一句。我认为这个问题更适合askubuntu页面。


Joh*_*Mee 6

大多数 Linux 包管理器提供大部分预编译的东西。以 Ubuntu 为例:

sudo apt install uwsgi-plugin-python3
Run Code Online (Sandbox Code Playgroud)

这将使uwsgi全局可用,而不仅仅是在该虚拟环境中,并且是安装 C 编译器的一种替代方法。


小智 6

这个命令对我有用sudo apt install build-essential python3-dev


Tes*_*ter 5

这是因为服务器上没有C编译器。如果您使用的是 AWS 等云上的实例,则gcc通常不会安装 Digital Ocean。所以需要手动安装

sudo apt update
sudo apt install gcc 
sudo pip install uwsgi # Sudo as the server requires root access
Run Code Online (Sandbox Code Playgroud)

应该解决问题

  • 切勿将“pip”与“sudo”一起使用。你会弄乱权限。您以前可能使用过 sudo pip,现在您在包文件夹中拥有混合权限,并且被迫一直使用 sudo (2认同)