Vs Code Python relative path error

#Question  

FileNotFoundError: [Errno 2] No such file or directory:’./XXX’

When ensuring that the file/directory does exist, the probability is the problem of the current running path of the program. Whether the code runner or the terminal is running, the default current path of vs code is not the path where the program file is located, so using the relative path to find the file will report an error.

#Settle

1. For code runner, modify its settings in expansion and check the option of file directory as CWD.

  2. For terminal operation, CD to the directory of program files first.


Read More: