ERROR: Failed building wheel for Twisted

error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1

今天在用Linux 用 pip 安装 Scrapy 时遇到以上错误。搞了我一个下午吐了真的,记录一下。

错误描述

使用 pip 安装 Scrapy 时:

pip install -U scrapy

出现以下错误:

unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for Twisted
  Running setup.py clean for Twisted
Failed to build Twisted
Installing collected packages: Twisted, scrapy
    Running setup.py install for Twisted ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, 
    ......

在这里插入图片描述
在这里插入图片描述

问题就是在安装 Scrapy过程中需要一个 Twisted 的依赖包,但安装失败了。起初我第一是去寻找这个依赖包去下载,然后自己手动安装,可是死活安装不了,总是提示:

unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

很长一段时间我以为是Twisted这个包的问题,但其实根本上是 gcc 和 python-dev 的问题

解决

网上查阅资料都说是 python-dev 的问题。
故我去安装了python3-dev,但还是不能解决,最后在 Stack Overflow 上找到正解:

除了下载 python-dev(python3用python3-dev),还要下载安装 gcc:

sudo apt-get install python3-dev
sudo apt-get install gcc

有的情况下只需要 python3-dev 就能解决,如果不行就应该是差了 gcc 了

Logo

更多推荐