Where is the Python interpreter that Sublime Text uses to run plugins?
Asked Answered
S

1

5

I'm trying to locate the Python interpreter that Sublime Text uses to run plugins.

Thinking that sys.executable would give me an absolute path to a Python interpreter, I tried creating this plugin:

from sys import version_info, executable    
from sublime_plugin import TextCommand

class GetPythonInfo(TextCommand):
    def run(self, edit):
        print(executable)
        print(version_info)

Output in Sublime console:

>>> view.run_command('get_python_info')
python3
sys.version_info(major=3, minor=3, micro=3, releaselevel='final', serial=0)

Since I don't have Python 3.3.3 installed elsewhere on my system, I assume that this interpreter was installed as part of Sublime somewhere. Is there a way to run this interpreter outside of Sublime, and if so, how?

There have been some questions (like this one) asking how to change the Python interpreter for the purposes of the build system. By contrast, I want to build a virtualenv specifically for Sublime plugin development. Ideally, this virtualenv would be based on the Python 3.3.3 interpreter that Sublime uses internally.

I'm using Sublime Text 3 on Mac OS X, but I'd be interested in answers for other systems/versions of Sublime.

Seadon answered 12/10, 2015 at 14:49 Comment(0)
V
8

Sublime's Python interpreter is compiled into the Sublime executable itself, so there is no way to run it outside of the program. What you can do is install the SublimeREPL package and run the Sublime REPL to have a little better access to the built-in interpreter.

Vermouth answered 12/10, 2015 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.