This code adds a Python library path relative to your working folder to enable you to load custom library functions from a Jupyter Notebook:
import sys, os
extra_path = os.path.join(os.getcwd(), "lib")
if extra_path not in sys.path:
sys.path.append(extra_path)
print('Added extra_path:', extra_path)
Then import like so:
import <my_file_name_in_lib_folder> as funcs
If in a Jupyter Notebook with Python 3.4+ the following will automatically reload the library:
import importlib
importlib.reload(funcs)
No comments:
Post a Comment