Skip to content

Instantly share code, notes, and snippets.

@RahulDas-dev
Created January 15, 2022 14:23
Show Gist options
  • Save RahulDas-dev/512761b05abf3851dfc7c1f323e19bc0 to your computer and use it in GitHub Desktop.
Save RahulDas-dev/512761b05abf3851dfc7c1f323e19bc0 to your computer and use it in GitHub Desktop.
Jupyter notebook import relative module from parent folder
import os
import sys
import inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
#print(currentdir)
parentdir = os.path.dirname(currentdir)
lib_path = os.path.join(parentdir,'src')
#print(parentdir, lib_path)
sys.path.insert(0,lib_path)
# ---then import library
import mycode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment