How to change the default Python interpreter in Sublime text 3(如何更改 Sublime text 3 中的默认 Python 解释器)
问题描述
我目前正在为我的项目使用 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 解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更改 Sublime text 3 中的默认 Python 解释器
基础教程推荐
- Discord.py 缺少必需的参数 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
