Creating a python module that calls functions from a module that requires installation in google colab

Viewed 49

in my colab notebook, I ran

!pip install unusual_module
from unusual_module import useful_function

Then I defined my_function in my collab notebook. This definition included a call touseful_funcion. This worked fine.

Since then I have created my_own_module.py which includes my_funcion. This .py is at the root directory of the notebook.

My notebook now begins with:

!pip install unusual_module
from unusual_module import useful_function
import my_own_module

These all run fine. However when i run my_funcion i get NameError: name 'useful_function' is not defined

I've tried:

  • having both !pip install unusual_module and from unusual module import useful_function at the start of my_own_module.py
  • from unusual module import useful_function at the start of my_own_module.py

both result in

NameError: name 'useful_function' is not defined

Why is this? and how do I fix it?

0 Answers
Related