Sana
Sana

Reputation: 563

import module in Jupyter notebook

I cloned a git project which has a folder called NOTEBOOKS and another folder called LOADER. In the LOADER folder, there is a data_loading.py. In the NOTEBOOKS folder there is a 01_analysis.ipynb, when I open this notebook using jupyter notebook and I want to run first cell:

from LOADER import data_loading

I get this error:

ModuleNotFoundError: No module named 'LOADER'

I am sure the code is correct but I need to tell Jupyter where the LOADER is. Is there anything which I need to add to the Jupyter to know where to fidn LOADER?

Upvotes: 0

Views: 163

Answers (1)

axr
axr

Reputation: 416

This is not related to jupyter notebook but python itself. A solution is to create a new module for data_loading.py and then install it globally thus allowing you to import it. An alternative will be to add LOADER to your path using

import sys  
sys.path.insert(0, 'path to LOADER')

and then import data_loading.

Upvotes: 3

Related Questions