Pythonbrew with Sublime Text

==========================

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 by switching the version of pythonbrew

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)

Set path in Sublime Text

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"
}

Switch the version with pythonbrew and check the version

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

Pythonbrew with Sublime Text
GOTO in Python with Sublime Text 3
Enable Python raw_input with Sublime Text 3
"Inline" Sublime Text plugin callbacks with a generator
Create a python3 build environment with Sublime Text3
Text mining with Python-Scraping-
Links to do what you want with Sublime Text
Set up a Python development environment with Sublime Text 2
Use python installed with Pyenv with Sublime REPL of Sublime Text 3
Text sentiment analysis with ML-Ask
Play with A3RT (Text Suggest)
W3C Validators didn't work with Sublime Text3 so I made it work
Text extraction with AWS Textract (Python3.6)
Added achievement function to Sublime Text
Text mining with Python ① Morphological analysis
Easy GUI app with Tkinter Text
Speak Japanese text with OpenJTalk + python
I made a package like Weblio pop-up English-Japanese dictionary with Sublime Text3
End-to-End Text Speech Synthesis Starting with ESPnet2
English speech recognition with python [speech to text]
Unsupervised text classification with Doc2Vec and k-means
Notes for installing Sublime Text on Ubuntu
Extract Japanese text from PDF with PDFMiner
Document classification with toch text from PyTorch
Text mining with Python ② Visualization with Word Cloud
Text filtering with naive bayes in sklearn
Create a matrix with PythonGUI (text box)
Read text in images with python OCR