Possible to switch between python 2 and 3 in Sublime Text 3 build systems? (Windows)

后端 未结 3 913
攒了一身酷
攒了一身酷 2021-01-06 13:08

All my current coding has been in python 3, which I\'ve installed via the Anaconda package. However I need to work on some code simultaneously in python 2. Is there a way I

3条回答
  •  不知归路
    2021-01-06 13:11

    Old question, but...

    On Windows, you dont need create a new build system or specify the absolute path. Edit already existing python build system.

    1. In SublimeText\Data\Packages\ create folder Python -> like this SublimeText\Data\Packages\Python\
    2. In this folder, create file Python.sublime-build , it will overwrite the existing python build system.
    3. In this file write (python launcher documentation):

      {
          "shell_cmd": "py -u \"$file\"",
          "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
          "selector": "source.python",
          "env": {"PYTHONIOENCODING": "utf-8"},
      }
      
    4. For choose version of python interpretator, in the first line of your scripts write (shebang lines)

      • #! python or
      • #! python3

提交回复
热议问题