Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 947
Ben Cook Avatar asked Oct 12 '15 14:10

Ben Cook


People also ask

Does Sublime Text have Python interpreter?

With Sublime repl, you press ctrl+b to start the code into a python interpreter inside sublime text itself, so that you do not have to open the cmd.

How do I configure Python interpreter in Sublime Text?

For language specific settings, click Sublime Text > Preferences > Settings - More > Syntax Specific - User. Then save the file using the following format: LANGUAGE. sublime-settings. For Python-specific settings, save the file as Python.

Which Python is sublime using?

Python Version By default, all plugins are run using Python 3.3. 6. Sublime Text's build of Python 3.3. 6 includes a handful of patches backported from Python 3.4 to fix issues with unicode paths and crashes with the ctypes module on 64bit versions of Windows.

How do I use plugins in Sublime Text?

Once Package Control is installed, you can use this to install the below packages as follows: Go to SublimeText – Preferences – Package Control (MAC) or Preferences – Package Control (PC) Choose “Install Package” from the list of options. Find the name of the package you wish to install and select it.


1 Answers

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.

like image 94
MattDMo Avatar answered Sep 30 '22 02:09

MattDMo