• 【linux】centos7 & ubuntu20.04 安装uwsgi报错解决


    centos

    在centos7中用pip install uwsgi,老是报错,原因是没有安装依赖,解决思路参考如下。

    1.安装编译

    yum install -y gcc* pcre-devel openssl-devel
    

    2.安装依赖

    yum install -y python-devel
    

    3.安装uwsgi

    pip install uwsgi
    

    ubuntu

    在ubuntu20.04中使用pip3 install uwsgi,和centos中报错类似,具体如下:

    # pip3 install uwsgi==2.0.15
    Looking in indexes: http://pypi.tuna.tsinghua.edu.cn/simple
    Collecting uwsgi==2.0.15
      Using cached https://pypi.tuna.tsinghua.edu.cn/packages/bb/0a/45e5aa80dc135889594bb371c082d20fb7ee7303b174874c996888cc8511/uwsgi-2.0.15.tar.gz (795 kB)
    Building wheels for collected packages: uwsgi
      Building wheel for uwsgi (setup.py) ... error
      ERROR: Command errored out with exit status 1:
       command: /usr/local/python-3.7.9/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-njytrn2x/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-njytrn2x/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-wc8d_vt3
           cwd: /tmp/pip-install-njytrn2x/uwsgi/
      Complete output (42 lines):
      /usr/local/python-3.7.9/lib/python3.7/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-njytrn2x/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-install-njytrn2x/uwsgi/setup.py", line 126, in <module>
          distclass=uWSGIDistribution,
        File "/usr/local/python-3.7.9/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
          return distutils.core.setup(**attrs)
        File "/usr/local/python-3.7.9/lib/python3.7/distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/usr/local/python-3.7.9/lib/python3.7/distutils/dist.py", line 966, in run_commands
          self.run_command(cmd)
        File "/usr/local/python-3.7.9/lib/python3.7/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/usr/local/python-3.7.9/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 335, in run
          self.run_command('install')
        File "/usr/local/python-3.7.9/lib/python3.7/distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/usr/local/python-3.7.9/lib/python3.7/distutils/dist.py", line 985, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-njytrn2x/uwsgi/setup.py", line 77, in run
          conf = uc.uConf(get_profile())
        File "/tmp/pip-install-njytrn2x/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
      ----------------------------------------
      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/local/python-3.7.9/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-njytrn2x/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-njytrn2x/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-n47e8yeh/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/python-3.7.9/include/python3.7m/uwsgi
             cwd: /tmp/pip-install-njytrn2x/uwsgi/
        Complete output (29 lines):
        /usr/local/python-3.7.9/lib/python3.7/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-njytrn2x/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-install-njytrn2x/uwsgi/setup.py", line 126, in <module>
            distclass=uWSGIDistribution,
          File "/usr/local/python-3.7.9/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
            return distutils.core.setup(**attrs)
          File "/usr/local/python-3.7.9/lib/python3.7/distutils/core.py", line 148, in setup
            dist.run_commands()
          File "/usr/local/python-3.7.9/lib/python3.7/distutils/dist.py", line 966, in run_commands
            self.run_command(cmd)
          File "/usr/local/python-3.7.9/lib/python3.7/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/tmp/pip-install-njytrn2x/uwsgi/setup.py", line 77, in run
            conf = uc.uConf(get_profile())
          File "/tmp/pip-install-njytrn2x/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
        ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/local/python-3.7.9/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-njytrn2x/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-njytrn2x/uwsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-n47e8yeh/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/python-3.7.9/include/python3.7m/uwsgi Check the logs for full command output.
    
    

    其实出现此问题原因也是因为缺少gcc编译器,建议先换阿里云源,然后安装gcc,

    阿里云源链接----->

    如果提示缺少wheel, pip3 install wheel:

    # 先安装gcc
    apt install -y gcc
    
    # pip安装包
    pip3 install uwsgi
    

  • 相关阅读:
    VisualSVN 服务不能自动启动的问题
    "There is already an open DataReader associated with this Command which must be closed first"错误
    LINQ 中调用存储过程自动绑定列名
    vs2008中调试iis7.0托管的程序
    SQL SERVER 2005的一个怪问题: 在查询结果面板中编辑失败.
    在VS2003下把一个DataTable Update 到数据库
    帮人解决一个小问题:QQ空间登录时脚本错误造成无法登入
    关于Sys未定义错误
    多层母版页嵌套中, 内层母版页的事件默认不触发
    线程同步
  • 原文地址:https://www.cnblogs.com/davis12/p/14416028.html
Copyright © 2020-2023  润新知