作为一名iOS开发者,最近捣腾起了Python(Python大法好,谁用谁知道)。准备写个网络爬虫,在安装Scrapy框架时就遇到了坑。
1、安装Python
笔者使用的macOS自带Python(其它系统请自行搜索Python安装方法)。以下操作均在终端进行。
python
Python 2.7.10 (default, Jul 30 2016, 19:40:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information.
2、安装pip
就像写iOS你得装个CocoaPods,用Ruby你得装个gem;pip就是Python的包管理工具了。
sudo easy_install pip
安装完pip后就可以使用pip安装Python众多强大的三方库以及框架
3、使用pip安装Scrapy
输入指令:
sudo pip install Scrapy
对于很多第三方库,这样一行代码就可以大功告成,但是这里:

大段的报错,分析问题,找到红色前面一句
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
是six1.4.1要被废弃了,建议我们卸载six1.4.1。找到问题了,其实我们没必要卸载six1.4.1。我们在安装Scrapy时忽略它就可以了。
sudo -H pip install Scrapy --upgrade --ignore-installed six
安装完之后我们输入
scrapy -v
输出版本信息
Scrapy 1.3.3 - no active project
安装成功,可以继续愉快地捣腾自己的爬虫了。
网友评论