11

I just started using Sublime Text 2 and was wondering, to sort of make it a full featured python IDE, if there was a way to change the integrated python interpreter to target the system python install rather than the one that came with Sublime. The reason is because I would like to use my python libraries that I have on my computer with the python interpreter.

I am aware of running python code in sublime using my version of python as explicitly shown here: How do I run Python code from Sublime Text 2?

However, this does not change the version of the python interpreter that you are running.

Any ideas?

2 Answers 2

17

Tools > Build System > New Build System. Insert the file and with your python version:

{
  "cmd": ["python3", "-u", "$file"],
  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
  "selector": "source.python"
}
3
  • I tried what you said, with python version ["/Library/Frameworks/Python.framework/Versions/Current/bin/python" since I have many python version :(, when I try to run the program on shell, it runs fine, but with sublime, I see print soup.prettify() UnicodeEncodeError: 'ascii' codec can't encode character u'\xbb' in position 6231: ordinal not in range(128), My code is #! /usr/bin/env python import urllib2 from bs4 import BeautifulSoup f = urllib2.urlopen('http://www.google.com') soup = BeautifulSoup(f.fp) print soup.prettify()
    – daydreamer
    Commented Jan 9, 2013 at 18:31
  • 1
    To get the above advice to work on OS X I needed to add a symbolic link into usr/bin to the location of my Python 3.3 installation. Like this: sudo ln -s "/Library/Frameworks/Python.framework/Versions/3.3/bin/python3" ./usr/bin/python3
    – jwpfox
    Commented Mar 3, 2013 at 9:31
  • 1
    I'm not sure why and maybe someone else can clear it up for me, but when I put "python2" where it says "python3", the build system did not work. Changing "python3" to "C:\\Python27\\python.exe" did work for me however.
    – Dante
    Commented Oct 4, 2015 at 5:08
1

According to the documentation referenced by the Sublime Text website itself, the embedded Python intrepreter is not intended for general development. This restricted usage recommendation even applies to ST2 for OS X, which is the only version that does use the system's Python version. So it's probably better to use the Build System workflow, or use a ST plug-in. Or switch to a purpose-built IDE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.