将 Sublime Text 2 包定向到正确的 python 安装

问题描述

我只想将一个 Sublime Text 2 包 (SublimeREPL) 指向 正确 python 安装——目前,它选择了错误的.

I just want to direct a Sublime Text 2 Package (SublimeREPL) to the correct python installation--at the moment, it's picking up the wrong one.

Mac 用户对这里的故事很熟悉.Mac OS 包含一个 python 安装,它用于需要 python 的各种操作系统内容.像许多其他人一样,我不喜欢使用这个系统 python(它位于/System/Library/...),因为它通常已经过时,当然更新它不是一个好主意——它是一个工作 pythonMac OS 使用的安装,以及更新导致依赖于该安装的操作系统任务中断的风险.

The story here is familiar to Mac users. The Mac OS comes includes a python install which it uses for various OS stuff for which python is required. Like many others, i prefer not to use this system python (which resides in /System/Library/...) becasue it is usually out of date and of course it's not a good idea to update it--it is a working python install used by the Mac OS, and updating risks causing those OS tasks that depend on that install to break.

但这是 SublimeREPL 包选择的版本:

But that's the version picked up by the package SublimeREPL:

Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

我用于开发的版本(安装在/Library/Frameworks/并符号链接到/usr/local/bin)是:

The version i use for development (and which is installed in /Library/Frameworks/ and symlinked to /usr/local/bin) is:

@ > python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Sublime 2 Text 在其他地方选择了正确的版本,except 在使用 SublimeREPL 包时,因此必须在该包中的一个配置文件中进行设置,让我将 SublimeREPL 定向到正确的python.

Sublime 2 Text is picking up the correct version elsewhere, except when using the SublimeREPL Package so there must be a setting in one of the config files in that Package that will let me direct SublimeREPL to the correct python.

但我找不到它.

似乎我已经用尽了所有可能的选项,查看我的/Sublime Text 2/Packages/目录必须位于以下任一位置:

It seems that i have exhausted all plausible options, which, looking through my /Sublime Text 2/Packages/ directory must reside in either:

SublimeREPL/

    SublimeREPL (OSX).sublime-settings
    SublimeREPL.sublime-settings

或者

User/

    SublimeREPL.sublime-settings

其实上面的三个 JSON文件我都添加了如下,没有任何效果:

In fact, i added the following each of the three JSON files above, with no effect:

{
    "default_extend_env": {"PATH": "/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin/python2.7:{PATH}"}
}


解决方案

如果你想使用 repl_open 你可以编辑配置中的 cmd 参数.我正在使用 Ubuntu,它位于:

If you want to use repl_open you could edit the cmd parameter in the config. I am using Ubuntu and it is located in:

/home/stav/.config/sublime-text-2/Packages/SublimeREPL/config/Python/Main.sublime-menu

{"command": "repl_open",
"caption": "Python",
"id": "repl_python",
"mnemonic": "p",
"args": {
  "type": "subprocess",
  "encoding": "utf8",
  "cmd": ["/usr/local/bin/python", "-i", "-u"],
  "cwd": "$file_path",
  "syntax": "Packages/Python/Python.tmLanguage",
  "external_id": "python"
  }
},

相关文章