how do i run python 3.5 in sublime text 3

  • Last Update :
  • Techknowledgy :

Yes, you can use any Python version you want to run programs from Sublime - you just need to define a new build system. Select Tools -> Build System -> New Build System, then delete its contents and replace it with:

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

if you have installed python3 and SublimeREPL, you can try setting up key bindings with the correct path to the python3 file.

[{
   "keys": ["super+ctrl+r"],
   "command": "repl_open",
   "caption": "Python 3.6 - Open File",
   "id": "repl_python",
   "mnemonic": "p",
   "args": {
      "type": "subprocess",
      "encoding": "utf8",
      "cmd": ["The directory to your python3.6 file", "-i", "$file"],
      "cwd": "$file_path",
      "syntax": "Packages/Python/Python.tmLanguage",
      "external_id": "python",
      "extend_env": {
         "PYTHONIOENCODING": "utf-8"
      }
   }
}]

Suggestion : 2

Use Futurize (or Modernize) to update your code (e.g. python -m pip install future),Use Pylint to help make sure you don’t regress on your Python 3 support (python -m pip install pylint),Once your dependencies are no longer blocking you, use continuous integration to make sure you stay compatible with Python 2 & 3 (tox can help test against multiple versions of Python; python -m pip install tox),Consider using optional static type checking to make sure your type usage works in both Python 2 & 3 (e.g. use mypy to check your typing under both Python 2 & Python 3; python -m pip install mypy).

import sys

if sys.version_info[0] == 3:
   from importlib
import abc
else:
   from importlib2
import abc
import sys

if sys.version_info[0] > 2:
   from importlib
import abc
else:
   from importlib2
import abc
try:
from importlib
import abc
except ImportError:
   from importlib2
import abc
from __future__
import absolute_import
from __future__
import division
from __future__
import print_function

Suggestion : 3

In Sublime Text, install MagicPython package via “Package Control” and disable the built-in Python package (using Package Control -> Disable Package, or directly by adding "Python" to "ignored_packages" in the settings file).,In Atom, install the MagicPython package and disable the built-in language-python package.,copy the MagicPython package into the Sublime/Atom/VSCode user packages directory;,This is a package with preferences and syntax highlighter for cutting edge Python 3, although Python 2 is well supported, too. The syntax is compatible with Sublime Text, Atom and Visual Studio Code. It is meant to be a drop-in replacement for the default Python package.

def some_func(a, # nothing fancy here, yet

   b: 'Annotation: '
   # implicitly '"foo" for Foo, '
   # concatenated '"bar" for Bar, '
   # annotation '"other" otherwise' = 'otherwise'):
# no reason why this should cause the highlighter to
break
#
def some_func(a:
   # annotation starts here lambda x = None: {
      key: val
      for key,
      val in
      (x
         if x is not None
         else [])
   }
   # annotation ends here and below is the
   default
   for 'a' = 42):
# no reason why this should cause the highlighter to
break
#
def some_func() - > {
   'Some',
   # comments 'valid',
   # are 'expression'
   # good
}:
100_000_000_000 0b_1110_0101 0x_FF_12_A0_99