“你需要一个 C 编译器来构建 uWSGI” - 但是 gcc 已经存在

“你需要一个 C 编译器来构建 uWSGI” - 但是 gcc 已经存在

我收到以下错误:

~$ sudo apt install build-essential python2.7-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.4ubuntu1).
python2.7-dev is already the newest version (2.7.15-4ubuntu4~18.04.2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~$ which gcc
/usr/bin/gcc
~$ gcc
gcc: fatal error: no input files
compilation terminated.
~$ pip install uwsgi==1.9.20 --index-url=http://192.168.1.200/pypackages/simple/ --trusted-host 192.168.1.200
Collecting uwsgi==1.9.20
  Downloading http://192.168.1.200/pypackages/simple/uwsgi/uwsgi-1.9.20.tar.gz (731kB)
    100% |████████████████████████████████| 737kB 12.1MB/s 
Building wheels for collected packages: uwsgi
  Running setup.py bdist_wheel for uwsgi ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-u0AKpd/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp63xyFzpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying uwsgidecorators.py -> build/lib.linux-x86_64-2.7
  installing to build/bdist.linux-x86_64/wheel
  running install
  using profile: buildconf/default.ini
  detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/7/include', '/usr/local/include', '/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed', '/usr/include/x86_64-linux-gnu', '/usr/include']
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-u0AKpd/uwsgi/setup.py", line 109, in <module>
      distclass=uWSGIDistribution,
    File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/usr/lib/python2.7/dist-packages/wheel/bdist_wheel.py", line 240, in run
      self.run_command('install')
    File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-u0AKpd/uwsgi/setup.py", line 71, in run
      conf = uc.uConf(get_profile())
    File "uwsgiconfig.py", line 627, in __init__
      raise Exception("you need a C compiler to build uWSGI")
  Exception: you need a C compiler to build uWSGI

错误说我没有 C 编译器但是安装了 gcc。

答案1

uwsgi已在存储库中。它可能不是 1.9.20 版本,但仍应能满足您的需求(并且uwsgi与 PyPI 基本相同,只是预编译和可安装)。

要安装它及其 Python 3 插件,只需运行:

sudo apt install uwsgi uwsgi-plugin-python3

这将安装uwsgiPython 3 插件。然后您可以uwsgi --plugin=python3 ...照常执行以直接运行它。

话虽如此,如果您不想自己手动运行(尽管在某些情况下您可能需要这样做),您也可以设置uwsgi配置文件/etc/uwsgi/*.ini,然后启动这些服务,sudo systemctl stop uwsgi && sudo systemctl start uwsgi它将自动以守护进程的方式运行。但是,有关此内容的文档位于 uwsgi 的文档中,并且太复杂和深入,我无法在此处复制。我使用它在我的雇主的基于 UWSGI 的基础设施上运行三个 API,并从授权访问 API 点的 Web 端点将数据传递给它们,它工作得非常有效。

相关内容