Ali Athar
Ali Athar

Reputation: 335

TypeError: 'module' object is not callable in Google Colab

I am getting the error when I run this code in google Colab

folders = glob('/content/drive/MyDrive/Data/train/*')

[![enter image description here]

enter image description here

Upvotes: 0

Views: 1082

Answers (2)

Nishad Ahamed
Nishad Ahamed

Reputation: 21

For this issue, the path should be defined differently.

For that, initially import glob and drive module as mentioned below

from google.colab import drive
drive.mount('/gdrive')
import glob

And then using this, you can easily access the file as follows

folders = glob.glob('/gdrive/MyDrive/Datasets/Tomato/train/*')

Here if you see the difference in the copied path and the defined path is

'/content/drive/MyDrive/Datasets/Tomato/test' is what coppid form the drive

'/gdrive/MyDrive/Datasets/Tomato/train/*' is how you need to define the path

Upvotes: 0

Suresh Gautam
Suresh Gautam

Reputation: 893

You tried to use glob method directly, take the following code sample which was tested in Google colab environment. It should help to fix your issue.

from google.colab import drive
drive.mount('/gdrive')


import glob
path = glob.glob("/gdrive/MyDrive/*")
for file_or_folder in path:
    print(file_or_folder)

Upvotes: 1

Related Questions