I'm on Debian using python3.7. I have a network drive that I typically mount to /media/N_drive
with dir_mode=0777
and file_mode=0777
. I generally have no issues with reading/writing files in this network drive.
Occasionally, especially soon after mounting the drive, if I try to run any Python script with os.getcwd()
(including any imported libraries like pandas) I get the error FileNotFoundError: [Errno 2] No such file or directory
. If I cd up to the local drive (cd /media/
) the script runs fine.
Doing some reading, it sounds like this error indicates that the working directory has been deleted. Yet I can still navigate to the directory, create files, etc. when I'm in the shell. It only seems to be Python's os.getcwd()
that has problems.
What is more strange is that this behavior is not predictable. Typically if I wait ~1 hour after mounting the drive the same script will run just fine.
I suspect this has something to do with the way the drive is mounted maybe? Any ideas how to troubleshoot it?