系統(tǒng):macos
開發(fā)環(huán)境:sublime
Python版本:2.7 and 3.6
系統(tǒng)自動2.7版本,通過brew安裝了3.6:brew install python3
問題:存在兩個版本如何通過pip安裝包,python3.:pip3 install xxx,python2.:pip2 install xxx
只有一個版本:pip install xxx
sublime默認(rèn)連接為系統(tǒng)2.7版本,如何建立一個一個指向3.6的版本
which 指令查看python3的路徑 終端輸入:which python3可得到Python所在路徑
sublime 新建一個build 輸入一下信息即可
{
"cmd": ["/path/to/python3", "-u", "$file"],
"file_regex": "^[ ]File "(...?)", line ([0-9]*)",
"selector": "source.python"
}
則可以基于python3來運行程序
又一個坑: AttributeError: module 'numpy' has no attribute 'array'
uninstall numpy install numpy后還是無效,原因是自己的文件名就叫numpy,記得python導(dǎo)入模塊是先本文件目錄,在到包目錄,所有出現(xiàn)這個錯誤(以前遇到過,好久沒用,加上沒記錄又犯了這個錯誤),最后記得刪除.pyc這個文件
Python集合類:[] () {},{} ,列表,元組,字典,集合