Deepin下安装scrapy报错(亲测有效!)
-
问题描述
在deepin操作系统上,使用python3.6,通过sudo pip3 install scrapy安装时候,出现以下错误:
src/twisted/test/raiser.c:4:10: fatal error: Python.h: 没有那个文件或目录 #include "Python.h" ^~~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-bufg4kxn/twisted/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-avqmhez4/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-bufg4kxn/twisted/
-
问题原因
scrapy安装时,会自动安装twisted,然而,在安装twisted时缺少依赖.
-
解决办法
(1)安装python3-dev(注:deepin自带python2和3的环境,此处不要写错!)
sudo apt-get install python3-dev
(2)再安装scrapy
sudo pip3 install scrapy