on-internet
← Community

Google Colab custom module has no attribute

Stack Overflow ·

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/myfunc.py Then I created a *.ipynb file at the same folder. It is /content/gdrive/My Drive/Colab/test.ipynb In myfunc.py, the code is def somefunc(a) return a*2 In test.ipynb, the code is cd /content/gdrive/My\ Drive/Colab import myfunc myfunc.somefunc(2) Then it occurs error "AttributeError: module 'myfunc' has no attribute 'somefunc'" I also used dir(myfunc) in test.ipynb, which shows ['__builtins__', '__cached__', '__doc__', '_

Comments

Sign in or sign up to comment and upvote.

No comments yet.