1.安裝pip
pip是python包管理工具讽挟,Mac系統(tǒng)自帶Python,里面有easy_install
sudo easy_install pip
pip區(qū)分python2屋谭、python3,用其安裝的第三方報(bào)分別用不同的版本運(yùn)行耐亏,包在不同版本的系統(tǒng)庫(kù)中
2.pip警告
(1)使用命令:sudo pip install numpy時(shí),可能遇到:
The directory '/Users/huangqizhi/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
說(shuō)得很清楚郭怪,是pip目錄的屬主不是sudo的root用戶支示。如果必須用sudo pip,更改pip目錄屬主即可:
sudo chown root /Users/huangqizhi/Library/Caches/pip
(2)pip安裝時(shí)鄙才,可能遇到:
/Library/Python/2.7/site-packages/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
解決方法:安裝requests颂鸿,注意后面帶[security]:
pip install requests[security]
3.用pip安裝第三方庫(kù)時(shí)權(quán)限問(wèn)題
安裝pygame時(shí)報(bào)如下錯(cuò)誤:
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pygame'
由于El Capitan引入了SIP機(jī)制(System Integrity Protection),默認(rèn)下系統(tǒng)啟用SIP系統(tǒng)完整性保護(hù)機(jī)制攒庵,無(wú)論是對(duì)于硬盤還是運(yùn)行時(shí)的進(jìn)程限制對(duì)系統(tǒng)目錄的寫操作嘴纺。 這也是我們安裝ipython失敗的原因….
現(xiàn)在的解決辦法是取消SIP機(jī)制,具體做法是:
重啟電腦浓冒,按住Command+R(直到出現(xiàn)蘋果標(biāo)志)進(jìn)入Recovery Mode(恢復(fù)模式)
左上角菜單里找到實(shí)用工具 -> 終端
輸入csrutil disable回車
重啟Mac即可
如果想重新啟動(dòng)SIP機(jī)制重復(fù)上述步驟改用csrutil enable即可
yyzanlldeMacBook-Pro:~ yyzanll$ csrutil status
System Integrity Protection status: disabled.
另一種方式為:
不一定成功
sudo pip install pygame --upgrade --ignore-installed
或者:
$ pip install --upgrade pip
$ sudo pip install numpy --upgrade --ignore-installed
$ sudo pip install scipy --upgrade --ignore-installed
$ sudo pip install scikit-learn --upgrade --ignore-installed
4.安裝scrapy
安裝scrapy遇到的坑
5.安裝requests
pip install requests
6.安裝BeautifulSoup4
pip install BeautifulSoup4
7.使用Chrome瀏覽器
8.安裝jupyter
pip install jupyter
jupyter notebook
9.安裝firebug