Skip to content Skip to sidebar Skip to footer

Directing Sublime Text 2 Packages To The Correct Python Installation

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. The story here is familiar to Mac use

Solution 1:

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

Solution 2:

@Steven Almeroth solution did not work for me.

Instead a changed a parameter in the following directory: packages/Python/Python.sublime-build

The following code is available there. Simple change the cmd to the directory where your brew of python is located.

{
"cmd": ["/Library/Frameworks/Python.framework/Versions/2.7/bin/python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

Solution 3:

From my experience it's simpler to fix a mess around versions patching environment variables specifically for Sublime Text 2 process

The only straight and dumb solution I've found - hack environment variables for Sublime Text 2. This can be done creating .py file with any name in folder:

~/Library/ApplicationSupport/SublimeText2/Packages/User/

Just add paths you need there and all plugins will use those settings. See more information in Rob Dodson's blog post: http://robdodson.me/blog/2012/05/14/hacking-the-path-variable-in-sublime-text/

Example .py:

import os

LOCAL = '/usr/local/bin:/usr/local/sbin:'# Sublime's default path is# /usr/bin:/bin:/usr/sbin:/sbin
os.environ['PATH'] += ':'
os.environ['PATH'] += LOCAL

print'PATH = ' + os.environ['PATH']

Post a Comment for "Directing Sublime Text 2 Packages To The Correct Python Installation"