'FileNotFoundError: [Errno 2] No such file or directory: 'statistics.csv'
txt = open("statistics.csv")
Keep getting this error, FileNotFoundError: [Errno 2] No such file or directory: 'statistics.csv', however the file is in the same folder as main.py
Projects:
US_statistics:
statistics.csv
main.py
tried using path
C:\Users\user_name\OneDrive\Documents\CODE\Programs\Python\Projects\US_statistics\statistics.csv
yet I still get the same error.
used os.getcwd and os.path.realpath(file) and paths match up to where the files are.
Solution 1:[1]
Try to run it directly over
python main.py
instead of in a environment or over the run button from Visual Studio Code this should work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | redbasecap |