Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the built-in python in Sublime Text 2?

Questions like this: Change python interpreter - Sublime Text 2 are great for if you actually want to run Build against your Python code. However, I want plugins (such as SublimeRope) to run the Python of my choosing rather than the built-in Python, which happens to be 2.6

I work in Python 2.7, so the built-in Python 2.6 causes syntax errors to be raised often when trying to use SublimeRope.

I've found all sorts of ways to change the Python related to running code being worked on, but none that affect the Python used by the plugin.

I've been using:

import sys
print sys.version

in the plugin .py code to see what version is being run against it, and it's always the built-in 2.6

EDIT 1: I see there is a feature request into Sublime Text 2 to make Python 2.7 the embedded python: http://sublimetext.userecho.com/topic/105249-update-the-python-embedded-interpreter-to-27/ Please upvote that if there is no other way to do this.

EDIT 2: This issue for the plugin SublimeLinter is relevant: https://github.com/SublimeLinter/SublimeLinter/issues/13 Because of how that plugin is setup, it appears to be possible to use the system Python instead of the Sublime Text 2 embedded Python. I haven't been able to find an analogous way to change the Python used for the SublimeRope plugin.

like image 702
Bodhi Avatar asked Jan 16 '13 10:01

Bodhi


1 Answers

I have solved this by creating a custom build system.

this is for example what I am using:

{
    "cmd": ["/Library/Frameworks/Python.framework/Versions/Current/bin/python", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}
like image 120
Marco Pashkov Avatar answered Oct 18 '22 17:10

Marco Pashkov