命令:pip install Scrapy
查看报错,出什么错就解决什么问题
常见错误1:
src/twisted/test/raiser.c:4:20: fatal error: Python.h: 没有那个文件或目录
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
上面的说明依赖包没有装完
解决方案:
1、之前一直都是:sudo apt install python-dev 或者 sudo apt install python3-dev,结果都不成功,看了下原因:
1)
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
python-dev 已经是最新版 (2.7.11-1)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
2)
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
python3-dev 已经是最新版 (3.5.1-3)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
发现一个是2.7,一个是3.5
2、所以最后安装3.6版本的python-dev就可以了。·[解决方案]
sudo apt install python3.6-dev
常见错误2:
Could not find a version that satisfies the requirement pyasn1 (from service-identity->Scrapy) (from versions: )
No matching distribution found for pyasn1 (from service-identity->Scrapy)
解决方案:
升级pip
常见错误3:
building ‘twisted.test.raiser’ extension
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: https://visualstudio.microsoft.com/downloads/
解决方案
检测scrapy安装是否成功
命令:scrapy
出现:
Scrapy 1.5.1 - no active project
Usage:
scrapy <command> [options] [args]
Available commands:
bench Run quick benchmark test
fetch Fetch a URL using the Scrapy downloader
genspider Generate new spider using pre-defined templates
runspider Run a self-contained spider (without creating a project)
settings Get settings values
shell Interactive scraping console
startproject Create new project
version Print Scrapy version
view Open URL in browser, as seen by Scrapy
[ more ] More commands available when run from project directory
Use "scrapy <command> -h" to see more info about a command