'File exists but Colab says no such file found

I mounted the files from google drive correctly with the following code.

from google.colab import drive
drive.mount('/content/gdrive')
base_path = "/content/gdrive/MyDrive/Colab\ Notebooks/data"
CAPUCHIN_FILE = os.path.join(base_path, 'Parsed_Capuchinbird_Clips', 'XC3776-3.wav')
print(CAPUCHIN_FILE) # prints /content/gdrive/MyDrive/Colab\ Notebooks/data/Parsed_Capuchinbird_Clips/XC3776-3.wav

My ls command proves that the file exists.

However, when trying to open it with Tensorflow-io, Colab notebook thinks it is not there.

What is happening here?

enter image description here

I have tried kernel restart and forced unmount. Still doesn't work.



Solution 1:[1]

You have a backslash in your base_path. The ls command and Python's string handling might escape that backslash differently.

base_path = "/content/gdrive/MyDrive/Colab Notebooks/data"

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