简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM