安装Scrapy for python3时出错

Ani*_*ddh 1 python ubuntu failed-installation scrapy

我使用pipUbuntu中安装Scrapy for Python3

sudo pip3 install scrapy
Run Code Online (Sandbox Code Playgroud)

安装时我收到此错误

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-3.5/src/twisted/test/raiser.o
    src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_il8a07a/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-9935fpm4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_il8a07a/Twisted/
Run Code Online (Sandbox Code Playgroud)

Tar*_*ani 5

如前所述,您缺少dev依赖项

对于python 2

sudo apt install -y python-dev
sudo pip install scrapy
Run Code Online (Sandbox Code Playgroud)

对于python 3

sudo apt install -y python3-dev
sudo pip3 install scrapy
Run Code Online (Sandbox Code Playgroud)