本文介绍了sublime text 2 控制台和 python 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 sublime text 2(并使用 python3.2 构建)中为构建命令设置 python3.2,但是当使用 -- the interpreter is mac's default 2.6 version.Any help is greatly appreciated!

推荐答案

Sublime Text 2 中的控制台使用 Python 的内部版本,即 2.6.没有办法在不破坏一大堆东西的情况下改变它.不过,有一个解决方法.如果你只想在 ST2 中使用 Python 控制台,请使用很棒的 SublimeREPL 包,它也可以通过 包控制.在许多其他事情中,您可以发送选择或整个文件以通过您选择的 REPL 进行解释,包括 Python 3.使用创建 Packages/User/SublimeREPL/config/Python/Main.sublime-menu以下内容:

The console in Sublime Text 2 uses the internal version of Python, which is 2.6. There is no way to change it without breaking a whole bunch of stuff. There is a workaround, though. If you just want a Python console within ST2, use the awesome SublimeREPL package, which can also be installed through Package Control. Among many other things, you can send selections or whole files to be interpreted through a REPL of your choice, including Python 3. Create Packages/User/SublimeREPL/config/Python/Main.sublime-menu with the following contents:

[
     {
        "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": ["python3", "-i", "-u"],
                        "cwd": "$file_path",
                        "syntax": "Packages/Python/Python.tmLanguage",
                        "external_id": "python",
                        "extend_env": {"PYTHONIOENCODING": "utf-8"}
                        }
                    }
                ]
                }
            ]
            }]
        }
]

"cmd" 选项更改为 python3 二进制文件的完整路径.这样,您的更改将在任何 SublimeREPL 升级中幸存下来.顺便说一句,此路径适用于任何包,因此您可以随意自定义,而不必担心意外丢失所有内容.

changing the "cmd" option to the full path to your python3 binary. This way your changes will survive any SublimeREPL upgrades. BTW, this path works for any package, so you can feel free to customize away without fear of accidentally losing it all.

这篇关于sublime text 2 控制台和 python 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:17