How to install uWSGI package from PyPI

I have been handed an issue with our company as I have been deemed the “Linux Expert” so I can fix anything…ha.

We are trying to install GIT on a RHEL 9 server and ran into an issue with pip install not working correctly. I have no experience with Python or PIP, but none the less, I have been given the task to figure this out.

When running 'python -m pip install ‘uwsgi==2.0.*’ I get a bunch of errors:

> [root@LOCALHOST ~]# python -m pip install 'uwsgi==2.0.*'
> Collecting uwsgi==2.0.*
>   Using cached uwsgi-2.0.21.tar.gz (808 kB)
> Building wheels for collected packages: uwsgi
>   Building wheel for uwsgi (setup.py) ... error
>   ERROR: Command errored out with exit status 1:
>    command: /usr/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-w1mn136t
>        cwd: /tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/
>   Complete output (42 lines):
>   /usr/lib64/python3.9/distutils/dist.py:274: 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
>   using profile: buildconf/default.ini
>   detected include path: ['/usr/include', '/usr/local/include']
>   Traceback (most recent call last):
>     File "/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/uwsgiconfig.py", line 750, 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-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py", line 117, in <module>
>       setup(
>     File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
>       return distutils.core.setup(**attrs)
>     File "/usr/lib64/python3.9/distutils/core.py", line 148, in setup
>       dist.run_commands()
>     File "/usr/lib64/python3.9/distutils/dist.py", line 966, in run_commands
>       self.run_command(cmd)
>     File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
>       cmd_obj.run()
>     File "/usr/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 335, in run
>       self.run_command('install')
>     File "/usr/lib64/python3.9/distutils/cmd.py", line 313, in run_command
>       self.distribution.run_command(command)
>     File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
>       cmd_obj.run()
>     File "/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py", line 77, in run
>       conf = uc.uConf(get_profile())
>     File "/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/uwsgiconfig.py", line 758, in __init__
>       raise Exception("you need a C compiler to build uWSGI")
>   Exception: you need a C compiler to build uWSGI
>   ----------------------------------------
>   ERROR: 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
>     ERROR: Command errored out with exit status 1:
>      command: /usr/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-9fu0vfcv/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/uwsgi
>          cwd: /tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/
>     Complete output (29 lines):
>     /usr/lib64/python3.9/distutils/dist.py:274: 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-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/uwsgiconfig.py", line 750, 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-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py", line 117, in <module>
>         setup(
>       File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
>         return distutils.core.setup(**attrs)
>       File "/usr/lib64/python3.9/distutils/core.py", line 148, in setup
>         dist.run_commands()
>       File "/usr/lib64/python3.9/distutils/dist.py", line 966, in run_commands
>         self.run_command(cmd)
>       File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
>         cmd_obj.run()
>       File "/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py", line 77, in run
>         conf = uc.uConf(get_profile())
>       File "/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/uwsgiconfig.py", line 758, in __init__
>         raise Exception("you need a C compiler to build uWSGI")
>     Exception: you need a C compiler to build uWSGI
>     ----------------------------------------
> ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uuoplc2k/uwsgi_a522fa146829432e8030b57e1a1515c3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-9fu0vfcv/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/uwsgi Check the logs for full command output.

I have tried finding logs for hopefully finding what is causing this error with no luck. I really have no idea from this message what I need to be searching for in order to help understand this error.

It says right at the end of your output:

Exception: you need a C compiler to build uWSGI

Do you have a C compiler installed on the system where you’re running pip?

I’m confused. If you’re trying to install Git, why do you want uWSGI? sudo dnf install git should do the trick. Git is not written in Python.

There’s another hint of the same nature there:

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

It tried to fetch the gcc version, and split the resulting string, except since there isn’t a gcc, the result was None, and so it errored out there.

Was it by any chance gitweb you were trying to install? Or some other repository browser support? The answer still is going to be: install the distro packages and don’t give yourself premature grey hairs. gitweb at least is packaged for RHEL/Fedora.

1 Like

The basic issue here is that for some rather mysterious reasons, the uwsgi package doesn’t ship with pre-built binary wheels that can be easily installed with pip like nearly every other Python package, and rather requires everyone to build from source. To resolve this, you can do one of the following:

  • (Simplest) Tweak your install spec to point to the pyuwsgi package instead, which installs exactly the same package, just as a pre-built wheel insted of from source
  • Follow the instructions to install the required dependencies so you can build from source on any machine you need it on
  • Install the package from Conda-Forge with Conda (you’ll need a conda Python)
  • Install it with your OS/distro-specific package manager (apt, dnf, yum, pacman, ports, Homebrew, Choco, etc).

Also, not sure what installing Git has to do with installing uWSGI…