Alan.L
Alan.L

Reputation: 193

Colab: No such file or directory

I just found a problem about directory making on Colab.

  1. First, I checked the current working directory:

    import os
    
    !pwd
    >> /content/
    
  2. Then, I created a sub-directory and checked it as follows.

    data_path = '/content/kaggle_original_data_cats_dogs'
    !mkdir data_path
    !ls /content/
    >> adc.json  datalab  data_path  sample_data  sampleSubmission.csv  train.zip
    

Here, we can see that data_path is the third member of /content/.

  1. However, when I tried to change the working directory to data_path, I got:

    os.chdir(data_path)
    
    >> FileNotFoundError: [Errno 2] No such file or directory: '/content/kaggle_original_data_cats_dogs'
    

So far...I can't figure out what just happened? Is there anything wrong with the lines above?

Upvotes: 0

Views: 8303

Answers (1)

korakot
korakot

Reputation: 40928

The mistake is here

!mkdir data_path

It should be this instead:

!mkdir $data_path

Upvotes: 2

Related Questions