作為一名iOS開發(fā)者汞贸,最近搗騰起了Python(Python大法好,誰用誰知道)暗膜。準備寫個網(wǎng)絡爬蟲匀奏,在安裝Scrapy框架時就遇到了坑。
1学搜、安裝Python
筆者使用的macOS自帶Python(其它系統(tǒng)請自行搜索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
安裝成功愁溜,可以繼續(xù)愉快地搗騰自己的爬蟲了。