簡體   English   中英

Ubuntu 18.04上的VSCode無法運行Python程序

[英]VSCode on Ubuntu 18.04 cannot run a Python program

我正在嘗試在Ubuntu 18.04系統上將VSCode與Python 3.6結合使用。 我寫了一個“ hello world”程序。

msg = "Hello World"
print(msg)

如果我突出顯示它並按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
>>>

我真的不知道該如何解決。 請幫忙!

發生這種情況是因為您的終端仍在運行python。 vscode試圖在python終端中執行/usr/bin/python3.6 /home/nuria/hello/hello.py ,從使用Shift + Enter執行代碼時,該終端仍在運行。 只需退出python shell,一切都會正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM