Home python How to run Python3 code via sublimerepl?

How to run Python3 code via sublimerepl?

Author

Date

Category

File Packages / Sublimerepl / config / python / main.sublime-menu

[
 {
  "ID": "Tools",
  "Children":
  [{
    "CAPTION": "sublimerepl",
    "Mnemonic": "R",
    "ID": "Sublimerepl",
    "Children":
    [
      {"Caption": "Python",
      "ID": "Python",
       "Children": [
        {"Command": "REPL_OPEN",
         "CAPTION": "Python 3",
         "ID": "REPL_PYTHON3",
         "mnemonic": "p",
         "Args": {
          "Type": "subprocess",
          "Encoding": "UTF8",
          "CMD": ["/ USR // bin / python3", "-i", "-u"],
          "CWD": "$ FILE_PATH",
          "Syntax": "Packages / Python / python.tmlanguage",
          "external_id": "Python",
          "EXTEND_ENV": {"Pythonioencoding": "UTF-8"}
          }
        }
      ]
      }
    ]
    }]
  }
 ]

File Packages / Sublimerepl / config / main.sublime-menu

[
 {
  "ID": "Tools",
  "Children":
  [{
    "CAPTION": "sublimerepl",
    "Mnemonic": "R",
    "ID": "Sublimerepl",
    "Children":
    [
      {"Caption": "Python",
      "ID": "Python",
       "Children": [
        {"Command": "REPL_OPEN",
         "CAPTION": "Python 3",
         "ID": "REPL_PYTHON3",
         "mnemonic": "p",
         "Args": {
          "Type": "subprocess",
          "Encoding": "UTF8",
          "CMD": ["/ usr / bin / python3", "-i", "-u"],
          "CWD": "$ FILE_PATH",
          "Syntax": "Packages / Python / python.tmlanguage",
          "external_id": "Python",
          "EXTEND_ENV": {"Pythonioencoding": "UTF-8"}
          }
        }
      ]
      }
    ]
    }]
  }
]

Answer 1, Authority 100%

Starting the program on Python from SubLimeText with the Package SublimErepl installed from the menu:

tools & gt; Sublimerepl & gt; Python & gt; Python - Run Current File

or, if you need to start a combination of keys, add to Preferences & GT; KeyBindings – User:

[
  {"Keys": ["Ctrl + SHIFT + R"], "Command": "Repl_Open",
         "Caption": "Python - Run Current File",
         "ID": "REPL_PYTHON_RUN",
         "Mnemonic": "D",
         "Args": {
         "Type": "subprocess",
         "Encoding": "UTF8",
         "CMD": ["Python", "-u", "$ File_BaseName"],
         "CWD": "$ FILE_PATH",
         "Syntax": "Packages / Python / python.tmlanguage",
         "external_id": "Python",
         "EXTEND_ENV": {"Pythonioencoding": "UTF-8"}
  },
]

, where [“Ctrl + SHIFT + R”] – the desired key combination.

At the same time, SublimeText will execute your Python system interpreter command, that is, the default you are called when entering the Python command in the OS command prompt. If you have Python 3 there, then the same version will be called in SubLimeText.


Answer 2

Faced a problem that when trying to save the key combination around the code above, I received an error “Error Trying to Parse Settings Expected Value in Packages User Preferences Sublime Settings.”
I helped the following code

[
{"Keys": ["Ctrl + SHIFT + R"], "Command": "Run_existing_Window_Command", "Args":
{
  "ID": "REPL_PYTHON_RUN",
  "File": "Config / python / main.sublime-menu"
}}
]

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions