Try to search your question here, if you can't find : Ask Any Question Now ?

Google Colab custom module has no attribute

HomeCategory: stackoverflowGoogle Colab custom module has no attribute
bhawya asked 1 week ago

What I am trying to do is to define a function in a custom module on Google Colab.
I created a *.py file to define the function. It is

/content/gdrive/My Drive/Colab/

Then I created a *.ipynb file at the same folder. It is

/content/gdrive/My Drive/Colab/test.ipynb

In, the code is

def somefunc(a)
  return a*2

In test.ipynb, the code is

cd /content/gdrive/My Drive/Colab
import myfunc

Then it occurs error “AttributeError: module ‘myfunc’ has no attribute ‘somefunc'”

I also used


in test.ipynb, which shows


My function ‘somefunc’ is not in the attributes!!!

This problem only occurs on Colab. I tried it on my computer and an online Jupyter notebooks. They are both working correctly.

PS: No matter whether I put an empty file in the same folder or not, the problem always exists.

1 Answers
Best Answer
Amit answered 1 week ago
Your Answer

5 + 18 =

Popular Tags

WP Facebook Auto Publish Powered By :