7

I have a local (not in Colab) Jupyter notebook that calls a function from another Jupyter notebook, it works fine. I've used David Rinck's answer from here: import a function from another .ipynb file and used this line to import the function: from ipynb.fs.full.MyFunctions import MyFunction

I've imported these two notebooks into Colab and when I run the main notebook I get the following error: No module named 'ipynb.fs.full.MyFunctions'

What have I missed in the process of importing to Colab? (I've run !pip install ipynb in Colab as well)

Itai
  • 83
  • 1
  • 5

1 Answers1

2

You can use the import-ipynb package.

Starting by installing:

!pip install import_ipynb
import import_ipynb

Then,

 import "your .ipynb file"

For Example, I have a sqroot.ipynb file with a function

def sqroot(x):
  return x**.5

We can run this function using the following:

import sqroot
sqroot.sqroot(2)
Mohana
  • 459
  • 3
  • 13