Home > OS >  Vs code error "no such file or directory"
Vs code error "no such file or directory"

Time:05-20

I wrote the command python3 hackernews.py in the terminal but it shows the error /Library/Developer/CommandLineTools/usr/bin/python3: can't open file 'hackernews.py': [Errno 2] No such file or directory. It does exist, then why does it show this error?

CodePudding user response:

You need to enter the directory where hackernews.py is located and run it with command "python3 hackernews.py".

If you use the command in terminal in vscode. The terminal will default the workspace to the current folder.

For example, I have a file named time.py in a deep directory. I need to enter the directory where the it is located to run:

enter image description here enter image description here

CodePudding user response:

Because your terminal isn't at your Python file's folder. You need to travel to the directory contain it. Use cd command and keep focus on something like: C:\Users\ADMIN It is your folder you are in. Use dir to list all file and directory in the directory you are inside. Then you can cd [folder name] (without brackets) to get inside small folder. Use cd.. to go back to the parent folder.

  • Related