为 python3 安装 Scrapy 时出错
Error while installing Scrapy for python3
我使用 pip 为 Python3 安装了 Scrapy Ubuntu
sudo pip3 install scrapy
安装时出现此错误
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
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/
运行下面的命令
sudo apt install -y python3-dev
然后安装scrapy
sudo pip3 install scrapy
如前所述,您缺少开发依赖项
对于python 2
sudo apt install -y python-dev
sudo pip install scrapy
为python3
sudo apt install -y python3-dev
sudo pip3 install scrapy
我使用 pip 为 Python3 安装了 Scrapy Ubuntu
sudo pip3 install scrapy
安装时出现此错误
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
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/
运行下面的命令
sudo apt install -y python3-dev
然后安装scrapy
sudo pip3 install scrapy
如前所述,您缺少开发依赖项
对于python 2
sudo apt install -y python-dev
sudo pip install scrapy
为python3
sudo apt install -y python3-dev
sudo pip3 install scrapy