==========================
The Python version of the Sublime Text Plugin is 2.6.7, so I would like to switch the version from 3.2 or 2.7.
Build version_info.py with command + b on Mac and you will see the version 2.7.1.
version_info.py
import sys
print sys.version_info
sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)
Since the path of pythonbrew does not pass to Sublime Text, the version switching is not reflected, so I will modify pythonbrew a little and make it correspond.
Create a symbolic link for the current version when switching versions with pybrew's switch and use. Add it to the end of run_command. (Switch and use are the same code.)
python:~/.pythonbrew/scripts/pythonbrew/commands/switch.py
def run_command(self, options, args):
# (Abbreviation)
path = os.path.abspath(os.path.join(PATH_PYTHONS, '..', 'current'))
if os.path.isdir(path):
os.unlink(path)
os.symlink(os.path.abspath(os.path.join(PATH_PYTHONS, pkgname)), path)
python:~/.pythonbrew/scripts/pythonbrew/commands/use.py
def run_command(self, options, args):
# (Abbreviation)
path = os.path.abspath(os.path.join(PATH_PYTHONS, '..', 'current'))
if os.path.isdir(path):
os.unlink(path)
os.symlink(os.path.abspath(os.path.join(PATH_PYTHONS, pkgname)), path)
Add path to Python.sublime-build in Python for Packages. (Please change user arbitrarily.)
Python.sublime-build
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"path": "/Users/user/.pythonbrew/current/bin:/usr/bin:/bin:/usr/sbin:/sbin"
}
First check with use
$ pybrew use 2.7.2
If you check the version with command + b, 2.7.2 will be displayed.
sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0)
Next, check with switch
$ pybrew switch 2.6.7
If you check the version with command + b, 2.6.7 will be displayed.
(2, 6, 7, 'final', 0)
** Version switching is now reflected in Sublime Text. ** **
Recommended Posts