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

后端 未结 3 939
攒了一身酷
攒了一身酷 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:16

    Specify the absolute path to the version of Python. For example, if Python version 3 is located at /usr/bin/python3 and Python version 2 is located at /usr/bin/python2:

    Python 3 Build Configuration:

    {
        "cmd": ["/usr/bin/python3", "-u", "$file"],
        "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
        "selector": "source.python",
        "shell": true
    }
    

    Python 2 Build Configuration:

    {
        "cmd": ["/usr/bin/python2", "-u", "$file"],
        "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
        "selector": "source.python",
        "shell": true
    }
    

    Find the location of Python via which:

    $ which python
    /usr/bin/python
    
    $ which python3
    /usr/bin/python3
    
    $ which python2
    /usr/bin/python2
    

    See Build system of Sublime Text 3 executes a different version of PHP, it is the same principal.

提交回复
热议问题