[英]VSCode on Ubuntu 18.04 cannot run a Python program
I am trying to use VSCode with Python 3.6 on an Ubuntu 18.04 system. 我正在尝试在Ubuntu 18.04系统上将VSCode与Python 3.6结合使用。 I wrote a "hello world" program.
我写了一个“ hello world”程序。
msg = "Hello World"
print(msg)
If I highlight it and press shift+enter it runs without problem, but, if I right-click and select to execute the file in a terminal I get this error message. 如果我突出显示它并按Shift + Enter,它可以正常运行,但是,如果我右键单击并选择在终端中执行文件,则会收到此错误消息。
>>> /usr/bin/python3.6 /home/nuria/hello/hello.py
File "<stdin>", line 1
/usr/bin/python3.6 /home/nuria/hello/hello.py
^
SyntaxError: invalid syntax
>>>
I really don't know how to fix it. 我真的不知道该如何解决。 Please help!
请帮忙!
This is happening because your terminal is still running python. 发生这种情况是因为您的终端仍在运行python。 vscode is trying to execute
/usr/bin/python3.6 /home/nuria/hello/hello.py
in python terminal which is still running from when you executed code using Shift + Enter
. vscode试图在python终端中执行
/usr/bin/python3.6 /home/nuria/hello/hello.py
,从使用Shift + Enter
执行代码时,该终端仍在运行。 Just exit python shell and everything should work. 只需退出python shell,一切都会正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.