I can't make SublimeREPL run Python 3, instead it's running Python 2

我只是一个虾纸丫 提交于 2021-02-10 20:44:39

问题


As you can see from the following code: I am trying to run a simple code that checks the python version and takes the user's input:

import platform  
print(platform.python_version())      
msg = input("Hello, how are you? ")     
print(msg)

We know that Sublime doesn't take any user input in a default fashion, so that's why I installed SublimeREPL, the inconvenience that I'm having is that an error arrises when I run the code above in SublimeREPL:( The code runs fine (apart the fact that it can't take input) in Python 3.6.4 (As I intend) in the normal part of Sublime Text 3:

3.6.7
Hello, how are you?

But when the code is ran in SublimeREPL it displays that the code is being ran in Python 2.7.10, therefore the error occurs:

2.7.10.   
Hello, how are you? Good   
Traceback (most recent call last):    
  File "first.py", line 3, in <module>    
    msg = input("Hello, how are you? ")   
  File "<string>", line 1, in <module>   
NameError: name 'Good' is not defined    

    ***Repl Closed***

The only way that the string input will work in the SublimeREPL is if I use raw_input() or use quotes around the input, but they're very inconvenient and they're a hassle. Can someone provide me a solution in having SublimeREPL run in python 3.6.4? I've tried to look for a solution everywhere online, but nothing seems to be working. Btw I'm using a Mac, I just switched from Windows, and it worked fine on Windows I remember. Thanks.

来源:https://stackoverflow.com/questions/53714752/i-cant-make-sublimerepl-run-python-3-instead-its-running-python-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!