• 解决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 "", line 1, in
        File "/tmp/pip-install-IwFDiU/uwsgi/setup.py", line 143, in
          '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
              |          ^~~~~~~~~~
        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

    结果

    安装成功

  • 相关阅读:
    第二篇章:类加载子系统
    域名系统安全作业-DNS Cache Poisoning Attack Reloaded: Revolutions with Side Channels
    E中国集装箱涂料行业竞争态势及投资盈利预测报告2022-2028年
    【华为OD机试真题 JS】猜密码
    Grafana----基于Kubernetes平台部署Grafana Loki Promtail系统
    webpack构建vue项目 基础03 之es6语法转化、js代码压缩
    一次因没有找到iframe元素而怀疑selenium4是不是有问题?
    flink消费kafka时获取元数据信息
    每日学习03--List与ArrayList的区别以及Arraylist的方法
    Debezium系列之:记录源库表增加字段,debezium采集的数据丢失新增字段的原因和相对应的解决方法
  • 原文地址:https://blog.csdn.net/Kangyucheng/article/details/133219214