Home > OS >  File exists but Colab says no such file found
File exists but Colab says no such file found

Time:05-14

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.

CodePudding user response:

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"
  • Related