Reputation: 802
I have a .py
file I want to import
into my notebook. The file is in the same directory as my .ipynb
file. How to make it visible to that notebook (say files are named ./library.py
and ./experiment.ipynb
)?
Upvotes: 0
Views: 112
Reputation: 27843
Using Python 3 , you should be able to just do import .library
or from . import library
. More generally, you need the file to be on your $PYTHONPATH
(it's unrelated to Jupyter/IPython it's a Python thing), and you should consider packaging your file it will probably take you 5 minutes to make it installable and redistributable.
Upvotes: 1