mac安裝scrapy報錯

mac自帶的pyton版本為2.7,目前scrapy在2.7版本上運行最穩定

一、安裝步驟

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


三、使用國內的pip源

通常我們直接pip install 去安裝庫都會報出超時或者安裝得很慢甚至中斷。向大家分享使用國內pip源的方法


國內源:

新版ubuntu要求使用https源,要注意。

清華:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/

華中理工大學:http://pypi.hustunique.com/

山東理工大學:http://pypi.sdutlinux.org/

豆瓣:http://pypi.douban.com/simple/

臨時使用:

可以在使用pip的時候加參數 -i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,這樣就會從清華這邊的鏡像去安裝pyspider庫。

永久修改,一勞永逸:

Linux下,修改 ~/.pip/pip.conf (沒有就創建一個文件夾及文件。文件夾要加“.”,表示是隱藏文件夾)

內容如下:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host=mirrors.aliyun.com

windows下,直接在user目錄中創建一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini,內容同上。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容