sublime-text3 - 如何在sublime3 项目设置中设置 python 解释器的路径?
PHPz
PHPz 2017-04-17 17:44:09
0
1
446

我系统装有python2和python3,但某项目用的virtualenv的python,于是想把某项目的默认解释器设置成virtualenv中的python,可以怎么设置?

PHPz
PHPz

学习是最好的投资!

reply all(1)
Ty80

You can create a new Build System. Build System

点击 Tools -> Build System -> New Build System...,会弹出一个编辑界面,在这个界面里面可以写出你的自定义构建系统。

格式可以参考编辑器自带的,在编辑器安装目录的 Packages 文件夹有一堆 sublime-package 文件,实际上是一堆压缩文件,这里面有一个 *.sublime-build 文件就是默认的构建系统。比如默认的 Python 构建系统就是

{
    "shell_cmd": "python -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",

    "env": {"PYTHONIOENCODING": "utf-8"},

    "variants":
    [
        {
            "name": "Syntax Check",
            "shell_cmd": "python -m py_compile \"${file}\"",
        }
    ]
}

你就照着这个,把 shell_cmd 部分改过来,如果你要用 python3,就把第二行改成

"shell_cmd": "python3 -u \"$file\""

如果是 virtualenv 带的 python 环境,就改成相应的路径,写完后命名为 **.sublime-build 保存到默认路径,** 为取的名字。

在你的代码处把构建系统改为你自己写的(点击 Tools -> Build System -> **),之后就能通过快捷键 Ctrl+B

Click Tools -> Build System -> New Build System..., an editing interface will pop up, in which you can write your custom build system. #🎜🎜# #🎜🎜#For the format, you can refer to the one that comes with the editor. There are a bunch of sublime-package files in the Packages folder of the editor installation directory, which are actually a bunch of compressed files. , there is a *.sublime-build file inside which is the default build system. For example, the default Python build system is #🎜🎜# rrreee #🎜🎜# Just follow this and change the shell_cmd part. If you want to use python3, change the second line to #🎜🎜# rrreee #🎜🎜#If it is the python environment provided by virtualenv, change it to the corresponding path. After writing, name it **.sublime-build and save it to the default path, ** is the name. #🎜🎜# #🎜🎜#Change the build system to your own in your code (click Tools -> Build System -> **), and then use the shortcut key Ctrl +B to use your custom interpreter. #🎜🎜#
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template