Python 3 不适用于 Sublime Text 2 [英] Python 3 is not working with Sublime Text 2

查看:37
本文介绍了Python 3 不适用于 Sublime Text 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Sublime Text 2 一年多了,最近开始将它用于 Python.Sublime 有一个为 Python 构建的构建版本,我尝试使用它(内置版本用于 2.7.3 或我相信的 2.X 版本).我正在使用 Python 3.3.0.我已经编辑了 sublime-build 文件并将其更改为:

<代码>{"cmd": ["python3", "-u", "$file"],"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",选择器":source.python"}

正如在另一个线程上的 stackoverflow 上所建议的那样.我尝试重新启动 sublime 并尝试运行我的代码:

x = input("姓名:")打印(欢迎" + x)输入()

但是在底部的控制台中,当我使用 build (Ctrl+B) 运行时出现以下错误:

名称:回溯(最近一次调用最后一次):文件/home/andrew/grive/Documents/RandomProjects/PythonStuff/HelloWorld.py",第 32 行,在<模块>x = input("姓名:")EOFError:读取一行时的EOF[0.1s 内完成,退出代码为 1]

此外,我试图通过仅使用 SublimeREPL 和其中的 Python 函数来绕过内置构建函数,但它们也检测到我的 Python 构建为 2.7.3,因此不会编译我的 3.3.0 代码.请注意,我确实安装了 Python 3,我使用的是 Ubuntu,当我在终端中键入python3"时,Python 在终端中以正确的版本启动.

所以我有两个问题:

为什么我的 python3.sublime-build 不工作,我该如何解决?

而且由于我是 Linux 菜鸟,因此无法访问构建文件.我去过他们一次,但我现在忘记了.它们在/home/~.config/sublime-text-2/等等等等.

我看不到 .config 文件,你能解释一下这是如何工作的吗?

解决方案

您的问题是 sublimetext 构建不能接受用户输入 - 没有连接输入流.您的 Python 版本无关紧要.

但是,可以编写插件来接受输入!><小时>

至于配置文件,只需使用首选项 -> 浏览包"菜单项.

I have been using Sublime Text 2 for over a year and recently started using it for Python. Sublime has a built it build for Python which I tried using (the built in one is for 2.7.3 or something 2.X I believe). I am using Python 3.3.0. I already edited the sublime-build file and changed it to:

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

As suggested on stackoverflow on another thread. I tried restarting sublime and trying to run my code:

x = input("Name: ")
print("Welcome " + x)
input()

But at the console at the bottom I get the following error when I run with build (Ctrl+B):

Name: Traceback (most recent call last):
File "/home/andrew/grive/Documents/RandomProjects/PythonStuff/HelloWorld.py", line 32,      
in <module>
x = input("Name: ")
EOFError: EOF when reading a line
[Finished in 0.1s with exit code 1]

Also, I tried to bypass the built in build function by just using SublimeREPL and the Python functions in that, but they also detect my Python build to be 2.7.3 thus not compiling my 3.3.0 code. Note that I do have Python 3 installed, I am using Ubuntu and when I type "python3" in the terminal Python is launched in the terminal with the correct version.

So I have two questions:

Why is my python3.sublime-build not working and how can I fix it?

And since I am a linux noob, I am having trouble accessing the build files. I got to them once but I forgot how now. They are in /home/~.config/sublime-text-2/ etc etc etc.

I cannot see the .config file, for bonus points could you explain how this works?

解决方案

Your problem is that the sublimetext builds cannot take user input - there is no input stream connected. Your Python version is irrelevant.

However, it's possible to write a plugin to take input!


As for the config files, just use the "preferences -> browse packages" menu item.

这篇关于Python 3 不适用于 Sublime Text 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆