I am writing my modules in jupyter notebooks and store them in a folder, say, /Users/me/myModules
(Note: the actual path contain spaces, does it matter?)
I would like to import them from other jupyter notebooks which are in different locations. Since the modules have .ipynb extension, I start my code with import import_ipynb
.
I followed this answer and added
export JUPYTER_PATH="${JUPYTER_PATH}:/Users/me/myModules"
to the top line of my bash_profile file, and saved. Then I run source ~/.bash_profile
in terminal.
Now, when I run jupyter --paths
in terminal, I can see the path to myModules folder under the data section (not the config or runtime sections).
However, in my jupyter notebook
import import_ipynb
import myFirstModule
gives a ModuleNotFoundError: no module named 'myFirstModule'. I am using Python 3.6.10 (Anaconda).
How can I import the module from the jupyter path?
(Actually I found a solution by simply typing %cd '/Users/me/myModules'
at the beginning of each notebook, but then every saved file (for example exported image) goes in the myModules folder, which is something I don't want)