My question is related to this. I am using Python 3.6 in Jupyter Notebook. My project directory is /user/project
. In this directory I'm building a number of models and each has its own folder. However, there is a common functions.py
file with functions that I want to use across all models. So I want to keep the functions.py
file in /user/project
but be able to call it from an .ipynb
file in /user/project/model1
, /user/project/model2
, etc... How can I do this?
There is no simple way to import python files in another directory. This is unrelated to the jupyter notebook
Here are 3 solutions to your problem
import sys
sys.path.insert(1, '/path/to/application/app/folder')
import file
You can create a local module by having an empty __init__.py
file in the folder you want to import. There are some weird rules regarding the folder hierarchy that you have to take into consideration.
You can create a module for the file you wish to import and install it globally.