This question already has an answer here:
- import local function from a module housed in another directory with relative imports in jupyter notebook using python3 3 answers
I have used jupyter notebook for data analysis for quite sometime. I would like to develop a module in my jupyter notebook directory and be able to import that new module into notebooks. My jupyter notebook file directory can be represented as follows;
Jupyter notebooks\
notebook1.ipynb
new_module\
__init__.py
newfunction.py
currentnotebooks\
notebook2.ipynb
When use import new_module
in notebook1.ipynb it works however when I try the same command in notebook2.ipynb I get the following ImportError: No module named 'new_module'
. The two obvious solutions are A) move new_module into the currentnotebooks directory or B) move notebook2.ipynb up to the same level as new_module. I don't want to mess around with the file structure at all. Is this possible?