解决ubuntu系统python2.7安装uwsgi报错

背景

因为项目老旧,仍需使用python2.7,仍需要使用pip2 安装依赖。在安装uwsgi的时候,报错。

错误一

  Building wheel for uwsgi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-IwFDiU/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-IwFDiU/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/pip-wheel-6LMh94
       cwd: /tmp/pip-install-IwFDiU/uwsgi/
  Complete output (35 lines):
  /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'descriptions'
    warnings.warn(msg)
  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/local/include', '/usr/include']
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-IwFDiU/uwsgi/setup.py", line 143, in <module>
      'Programming Language :: Python :: 3.11',
    File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 162, 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/local/lib/python2.7/dist-packages/wheel/bdist_wheel.py", line 335, 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-install-IwFDiU/uwsgi/setup.py", line 77, in run
      conf = uc.uConf(get_profile())
    File "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
 

 解决办法

sudo apt install -y gcc

错误二

    [x86_64-linux-gnu-gcc -pthread] core/dot_h.o
    [x86_64-linux-gnu-gcc -pthread] core/config_py.o
    *** uWSGI compiling embedded plugins ***
    [x86_64-linux-gnu-gcc -pthread] plugins/python/python_plugin.o
    In file included from plugins/python/python_plugin.c:1:
    plugins/python/uwsgi_python.h:4:10: fatal error: Python.h: No such file or directory
        4 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-MZMAXI/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-MZMAXI/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-record-NlwlI9/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/kyc/.local/include/python2.7/uwsgi Check the logs for full command output.
 

 解决办法

 sudo apt-get install python2-dev

结果

安装成功

文章来源地址https://uudwc.com/A/pj3zN

原文地址:https://blog.csdn.net/Kangyucheng/article/details/133219214

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

上一篇 2023年09月24日 05:48
【Python从入门到进阶】37、selenium关于phantomjs的基本使用
下一篇 2023年09月24日 05:48