简体   繁体   中英

Im Trying To Run Python On Visual Studio Code But am Facing An File Not Found Error

I installed python and was using it with PyCharm For A Couple of Weeks Today I wanted to Swap To Visual Studio Code Because of Some Features. I Created A File and Set It To Python From The Bottom Right Corner, When I Try Running and Debugging It Shows Me An Error Message That Says "FileNotFoundError: [Errno 2] No such file or directory: 'C:\Untitled-1'PS C:> "

We can use cmd terminal and powershell terminal in VS Code.

When we run the code and the VSCode terminal is in the Python interactive window, the terminal displays: " SyntaxError: invalid syntax ": (Because the Python interactive window recognizes Python code, the run button is to execute a command with a path.)

在此处输入图像描述

Solution:

  1. Click the green run button in the upper right corner of VS Code:

    在此处输入图像描述

  2. Or enter "Python" in the terminal to enter the Python interactive window, and then enter the code in the terminal:

    在此处输入图像描述

For using Python in VS Code you could refer to this document: Python in VS Code .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM