Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jobel-code/8adffdd45a7d5780258ddfca1b35e273 to your computer and use it in GitHub Desktop.
Save jobel-code/8adffdd45a7d5780258ddfca1b35e273 to your computer and use it in GitHub Desktop.
Ensures that a modulle path, relative two levels down from the running jupyter notebook is accessible from the Jupyter Notebook. Assumes that you have a file directory that follows the [cookiecutter-data-science repo](https://drivendata.github.io/cookiecutter-data-science/#cookiecutter-data-science)
import os
import sys
# Cookicutter `data_science` Making the /src/ available as module from `/notebooks/dashboards/`
module_path = os.path.abspath(os.path.join('../..'))
print('{}'.format(module_path))
if module_path not in sys.path:
sys.path.append(module_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment