Failed building wheel for uwsgi
Asked Answered
C

5

37

I got an error,Failed building wheel for uwsgi. My environment is Ubuntu,now I wanna install uwsgi,so I run command pip install uwsgi.But error happens

 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/

I run command sudo apt-get -y install python-dev,but same error happens.I really cannot understand why these error happens.How should I fix this?Why am I told I need C compiler in uWSGI?How should I fix this?

Carline answered 18/12, 2017 at 12:6 Comment(0)
O
42

Your exception explicitly says what's wrong:

gcc_version_components = gcc_version.split('.')
AttributeError: 'NoneType' object has no attribute 'split'

and

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

So in general your system does not have c compiler installed (e.g. gcc). Try installing it. In Ubuntu it would be sudo apt-get install gcc.

BTW. I think this question would better fit askubuntu page.

Overture answered 18/12, 2017 at 12:10 Comment(0)
A
7

Most linux package managers offer most things precompiled. For example on Ubuntu:

sudo apt install uwsgi-plugin-python3

This will make uwsgi globally available, not just within that one virtualenv, and is an alternative to installing a C compiler.

Acetaldehyde answered 27/8, 2019 at 8:28 Comment(1)
well , when you use env python this it's not so good idea !!!Neibart
I
6

This command worked for me sudo apt install build-essential python3-dev

Iosep answered 11/6, 2023 at 0:4 Comment(0)
R
4

This is because there is no C compiler on the server. If you are using an instance on cloud like AWS or Digital Ocean gcc is typically not installed. So you need to install it manually

sudo apt update
sudo apt install gcc 
sudo pip install uwsgi # Sudo as the server requires root access

should solve the prolem

Redware answered 19/11, 2019 at 14:8 Comment(1)
never use pip with sudo. You'll mess up permissions. You've probably used sudo pip before and now you have mixed permissions in the package folder, and are forced to use sudo all the timeManagement
H
4

CentOS 7, python 3.11:

pip install uwsgi==2.0.23

The later version causes an error:

Building wheels for collected packages: uwsgi
  Building wheel for uwsgi (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for uwsgi (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      /tmp/pip-build-env-7vhdlmeh/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'descriptions'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib
      copying uwsgidecorators.py -> build/lib
      installing to build/bdist.linux-x86_64/wheel
      running install
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      gcc: error: unrecognized command line option ‘-Wformat-signedness’
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for uwsgi
Failed to build uwsgi
ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based projects

-Wformat-signedness is introduced in gcc 5, CentOS only has gcc 4.

Heartrending answered 9/2, 2024 at 5:26 Comment(1)
This was the answer to my question. I uninstalled uwsgi globally and in my environment first, then I installed using this version. And it worked!!!Chantalchantalle

© 2022 - 2025 — McMap. All rights reserved.