【uWSGI】ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based...

文章目录

  • 一、问题描述
  • 二、解决方法
  • 三、成功安装
  • 四、解决历程

一、问题描述

在 Python3.9 的 Anaconda 虚拟环境中安装 uWSGI 时出现以下报错:

	gcc: error: /home/mzx/anaconda3/envs/mysites/lib/python3.9/config-3.9-x86_64-linux-gnu/libpython3.9.a: 没有那个文件或目录
    	*** error linking uWSGI ***
    	[end of output]
  
 	note: This error originates from a subprocess, and is likely not a problem with pip.
 	ERROR: Failed building wheel for uwsgi
 	Running setup.py clean for uwsgi
Failed to build uwsgi
ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based projects

二、解决方法

使用 conda 安装即可,语句如下:

conda install -c conda-forge uwsgi

或者 使用下述语句(任选其一即可):

conda install -c "conda-forge/label/broken" uwsgi
conda install -c "conda-forge/label/cf201901" uwsgi
conda install -c "conda-forge/label/cf202003" uwsgi
conda install -c "conda-forge/label/gcc7" uwsgi

指令来源于 Anaconda 官网:https://anaconda.org/conda-forge/uwsgi
【uWSGI】ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based..._第1张图片

三、成功安装

使用上述命令后可以很轻松地成功安装:
【uWSGI】ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based..._第2张图片

四、解决历程

本部分仅记录一下本人走过的弯路,与解决方案无关。

【uWSGI】ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based..._第3张图片

  1. 在出现报错之后,首先试图安装编译依赖关系:sudo apt-get install build-essential python-dev
    【无功而返】
  2. 换为pyhton3sudo apt-get install build-essential python3-dev
    【无功而返】
  3. 尝试本地安装
    • 下载: wget https://files.pythonhosted.org/packages/a7/4e/c4d5559b3504bb65175a759392b03cac04b8771e9a9b14811adf1151f02f/uwsgi-2.0.22.tar.gz
    • 安装:pip install uwsgi-2.0.22.tar.gz
      【无功而返】
  4. 然后我打算从 required to install pyproject.toml-based projects 下手:
    • 安装 poetrypip install poetry
    • 然后,然后呢?
      【没下文了】
  5. 尝试直接安装 pyproject-toml:pip install pyproject-toml
    【无功而返】
  6. 然后决定从 gcc 缺少的那个文件下手,还真的发现一篇这样解决了问题的博客!!!
    • 文章链接:https://zhuanlan.zhihu.com/p/471389585
    • 不过由于操作起来过于麻烦,最后还是没有这样做。
      【知难而退】
  7. 最后偶然发现可以用 conda 直接安装。我真的,泪目了。
    【uWSGI】ERROR: Could not build wheels for uwsgi, which is required to install pyproject.toml-based..._第4张图片

参考文献
[1] Anaconda:https://anaconda.org/conda-forge/uwsgi
[2] 知乎文章:https://zhuanlan.zhihu.com/p/471389585

你可能感兴趣的:(踩坑笔记,ubuntu,conda,pip,django)