How to use different python versions in Sublime Repl for Sublime text 3

The sublime repl plugin for Sublime text is very useful, you can have your results in full color instead of black and white text, first of all.

Go in the install package system of sublime text:

  • goto tools / command palette (or ctrl+schift+p)
write inst and click on the first item you see there
wait some seconds and you will see this

Write repl and you will see the sublimerepl plugin. Install it.

After that go in preferences and choose keybindings.

And copy this (only the part for sublime repl, but if you install also terminus, you ca use the second part for it, it’s another very useful plugin to use the command line interface of windows or linux inside sublime text without have to use the external app of the cmd).

If you do not want to write it just copy and paste this text. Check if your python version in in the Python311 path like mine. If not, open python in the cmd, import sys and print sys.path[4] to see where your python.exe is

In my case is in this path, if yours is in in another path, change it inside the text
[




{"keys": ["ctrl+b"], "command": "repl_open",
 "caption": "SublimeRepl",
 "id": "SublimeRepl",
 "mnemonic": "R",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": ["C:/Users/giova/AppData/Local/Programs/Python/Python311/python.exe", "-u", "-i", "$file_basename"],
    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }},

]

The other part of this post is an older version… so it should not interest you. I leave it, just in case could be useful to somebody, who knows for what.

Speed up python testing with Sublime text and Sublime Repl

You can use some shortcut keys to run different versions of python for your code in sublime text 3 with the sublime repl plugin.

In the Window (default).sublime-keymap file

This can be found through preferences/browse pakages and then going into the user folder.

[

{"keys": ["ctrl+alt+p"], "command": "repl_open",
 "caption": "SublimeRepl",
 "id": "SublimeRepl",
 "mnemonic": "R",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": ["C:/Users/giova/AppData/Local/Programs/Python/Python37/python.exe", "-u", "-i", "$file_basename"],
    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }},


{"keys": ["ctrl+b"], "command": "repl_open",
 "caption": "SublimeRepl",
 "id": "SublimeRepl",
 "mnemonic": "R",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": ["C:/Users/giova/AppData/Local/Programs/Python/Python38/python.exe", "-u", "-i", "$file_basename"],
    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }},

        {"keys": ["ctrl+alt+b"], "command": "repl_open",
 "caption": "SublimeRepl",
 "id": "SublimeRepl",
 "mnemonic": "R",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": ["C:/Users/giova/AppData/Local/Programs/Python/Python311/python.exe", "-u", "-i", "$file_basename"],
    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }},
]

Whatch the video with the explanation of how to use the different versions of Python


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.