mac自帶的pyton版本為2.7,目前scrapy在2.7版本上運行最穩(wěn)定
一、安裝步驟
1.打開terminal薪前,輸入
$ sudo ruby ?-e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.安裝wget (若已安裝好wget,這步跳過)
$ sudo brew install wget
3.安裝command line tools
$ sudo xcode-select --install
4.安裝pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
5.安裝scrapy
$ sudo pip install scrapy
二关斜、報錯信息
OSError: [Errno 1] Operation not permitted: '/tmp/pip-1_nHcH-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
$ sudo pip install Scrapy --upgrade --ignore-installed six ?//表示忽略已安裝的six庫示括,因為mac的python自帶就有這個庫,然而這個庫版本比較舊
ImportError: cannot import name xmlrpc_client
$ sudo easy_install -U six
三痢畜、使用國內(nèi)的pip源
通常我們直接pip install 去安裝庫都會報出超時或者安裝得很慢甚至中斷垛膝。向大家分享使用國內(nèi)pip源的方法
國內(nèi)源:
新版ubuntu要求使用https源,要注意丁稀。
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中國科技大學(xué) https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學(xué):http://pypi.hustunique.com/
山東理工大學(xué):http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
臨時使用:
可以在使用pip的時候加參數(shù) -i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider吼拥,這樣就會從清華這邊的鏡像去安裝pyspider庫。
永久修改线衫,一勞永逸:
Linux下凿可,修改 ~/.pip/pip.conf (沒有就創(chuàng)建一個文件夾及文件。文件夾要加“.”授账,表示是隱藏文件夾)
內(nèi)容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
windows下矿酵,直接在user目錄中創(chuàng)建一個pip目錄,如:C:\Users\xx\pip矗积,新建文件pip.ini,內(nèi)容同上敞咧。