Is it possible to switch between python 2 and 3 in Sublime Text 3? (Windows)

All my current encoding was in python 3, which I installed through the Anaconda package. However, I need to work with some code at the same time in python 2. Is there a way to add a build system in Sublime so that I can switch between two fluid ones? I have both python 2 and 3 installed, however I see no way to just change the build system to switch between the two languages. The build system I use for python 3 is:

{ "cmd": ["python", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "shell": true } 

Thank you very much!

+3
source share
1 answer

Specify the absolute path to the Python version. For example, if Python version 3 is in /usr/bin/python3 , and Python 2 is in /usr/bin/python2 :

Python 3 build configuration:

 { "cmd": ["/usr/bin/python3", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "shell": true } 

Python 2 build configuration:

 { "cmd": ["/usr/bin/python2", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "shell": true } 

Find the Python location through which :

 $ which python /usr/bin/python $ which python3 /usr/bin/python3 $ which python2 /usr/bin/python2 

See Sublime Text 3 build system runs a different version of PHP , this is the same principle.

+3
source

Source: https://habr.com/ru/post/1258127/


All Articles