在MacOSX上重新安装Python (10.8) python 自然语言处理的前戏
因?yàn)橄雽W(xué)python自然語(yǔ)言處理就想在mac上重新配置一下python。
在網(wǎng)上找了很久才找到兩篇有用的教程http://765i.cn/%E5%9C%A8macosx%E4%B8%8A%E9%87%8D%E6%96%B0%E5%AE%89%E8%A3%85python-10-8/
http://woodpecker.org.cn/diveintopython3/installing-python.html
第一篇文章基本沒(méi)有問(wèn)題,但是使用了下發(fā)現(xiàn),還是少了一些命令。
第一步, 下載最新的Python版本
下載的地址就在http://python.org, 最新的版本是Python 2.7.3 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6 and 10.7),大約是18.8Mb。DMG的格式,下載完成,雙擊即可安裝,不需要任何設(shè)置,默認(rèn)的安裝路徑是 /Library/Frameworks/Python.framework,不過(guò)這和系統(tǒng)原有的路徑不一樣。因?yàn)橄到y(tǒng)之前是存在Python的,所以安裝成功后,在Terminal里運(yùn)行Python,看到的依舊是2.7.2的版本號(hào)。接下來(lái),我們要做的就是把原來(lái)的系統(tǒng)版本移除,讓新的版本正常工作
第二步, 把Python挪到正確的位置去
如第二步刪除系統(tǒng)原有的/System/Library/Frameworks/Python.framework/Versions/文件夾下的python
sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7使用完該命令以后要再系統(tǒng)文件下重新建立文件夾Version,sudo mkdir Version,反之無(wú)法繼續(xù)下面命令
sudo mv /Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions來(lái)移動(dòng)新的python到原來(lái)的系統(tǒng)路徑下。
第三步,修改文件所屬的Group
設(shè)置Group為wheel,原來(lái)系統(tǒng)自帶的就是這樣的。//這個(gè)很重要自己設(shè)置的時(shí)候沒(méi)注意
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/2.7但是其實(shí)我的電腦做到這一步就可以了,下面兩步感覺(jué)不是必須的。
第四步,更新一下Current的Link
在Versions的目錄里有一個(gè)Current的link,是指向當(dāng)前的Python版本,原始是指向系統(tǒng)自帶的Python2.7.2,我們把它刪除后,link就失效了,所以需要重新鏈一下這里的Current文件夾同樣需要重新設(shè)置。
sudo rm /System/Library/Frameworks/Python.framework/Versions/Current sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/Current
第五步,重新鏈接可執(zhí)行文件
1) 先把系統(tǒng)原來(lái)的執(zhí)行文件刪掉
sudo rm /usr/bin/pydoc sudo rm /usr/bin/python sudo rm /usr/bin/pythonw sudo rm /usr/bin/python-config
2) 建立新的鏈接
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc /usr/bin/pydoc sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/bin/python sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw /usr/bin/pythonw sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config /usr/bin/python-config
最后,更新一下.bash_profile文件
cd ~
vim .bash_profile (只要能編輯就行)
插入新的Python路徑
之后打命令python -V就可以看到版本是2.7.3
?
轉(zhuǎn)載于:https://www.cnblogs.com/bertrandwdx/archive/2013/03/05/2944035.html
總結(jié)
以上是生活随笔為你收集整理的在MacOSX上重新安装Python (10.8) python 自然语言处理的前戏的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Android 调整屏幕分辩率
- 下一篇: 初识python 2.x与3.x 区别