問題描述
我目前正在為我的項目使用 Anaconda python 發行版(不是 anaconda 插件,它們具有相同的名稱,但我使用的一個包括 Numpy、IPython 等.這有點令人困惑).所以我想將默認的python(v3.3)更改為Anaconda(v2.7.6)中的python,在這種情況下我將能夠使用嵌入在Anaconda中的庫.我試圖在 Tool > Build System > New Build System 下放置一個新腳本.
I am currently using the Anaconda python distribution for my project (NOT the anaconda plugin, they have the same name, but the one I am using includes Numpy, IPython, etc. It is kinda confusing). So I want to change the default python (v3.3) to the one in Anaconda (v2.7.6), in that case I will be able to use the libraries embedded in Anaconda. I tried to put a new script under Tool > Build System > New Build System.
{
"path": "/home/username/anaconda/bin",
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File "(...*?)", line ([0-9]*)",
"selector": "source.python"
}
但是失敗了,sublime還在使用默認解釋器:
But it failed, the sublime is still using the default interpreter:
>>>print (sys.version)
3.3.0 (default, Jun 12 2013, 17:01:35)
[GCC 4.7.2]
>>> print (sys.executable)
python3
>>> print (sys.path)
['/opt/sublime_text', '/opt/sublime_text/python3.3.zip', '/home/username/.config/sublime-text-3/Packages']
所以我的問題很簡單(但對于不知道的人來說已經夠難了):如何將此默認 python 解釋器更改為我想要的解釋器;
So my question is quite simple (but hard enough for one who doesn't know): How to change this default python interpreter to the one I want;
推薦答案
你可以通過區分python的名字來讓它工作.
You can get it working by distinguishing the name of python.
例如改變
C:Python27python.exe
到
C:Python27python2.exe
更改您的環境變量以引用此更改.在 cmd 中輸入 python2 以確認它的工作.
Change your environment variables to reference this change. Type python2 in cmd to confirm its working.
然后你應該能夠從你的構建熱鍵中引用它.
And then you should be able to reference this from your build hotkey.
{
"path": "/home/username/anaconda/bin",
"cmd": ["python2", "-u", "$file"],
"file_regex": "^[ ]*File "(...*?)", line ([0-9]*)",
"selector": "source.python"
}
這篇關于如何更改 Sublime text 3 中的默認 Python 解釋器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!