I am experiencing an error where I am looking for a .csv file that exists on disk and the code is not acknowledging the existence of the file, which is given by an absolute path. os.path.exists()
returns False
when executing the script but returns True
when executing in the REPL. I am using the same virtual environment to run both, and am running the script and REPL from the same directory.
I have tried:
- Stripping the whitespace from the absolute path with
strip()
- I am using the same variable and hence consistent spelling for the absolute path
- I have run
sudo chmod -R a+rwx <path>
on the file to address any potential permissions issue.
did you try using full path, sometimes python doesn’t respond with the relative paths.
Basel Mohamed Alam Elden is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.