Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

sublimetext3 - How to change the default Python interpreter in Sublime text 3

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"
}

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']

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;

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can get it working by distinguishing the name of python.

For example change

C:Python27python.exe 

to

C:Python27python2.exe

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"
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...