Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

How to import Python code in src folders when using notebooks? #4

Open
davidrpugh opened this issue Oct 3, 2018 · 3 comments
Open

Comments

@davidrpugh
Copy link

How do you import python modules defined in the src sub-directories when using Jupyter notebooks residing in the notebook directory?

@davidrpugh
Copy link
Author

My current solution is to do the following in the notebooks...

import sys

sys.path.append("..")
from src.data import ???

...where ??? should be replaced by whatever scripts you are importing.

@rkoppula
Copy link

rkoppula commented Oct 3, 2018

That's the solution we use as well. In next release we could add export PYTHONPATH="$PYTHONPATH:/mnt" as environment variable in the image.

@davidrpugh
Copy link
Author

@rkoppula I think it might be better to explicitly document the need to import the scripts as above rather than append the PYTHONPATH variable in the Dockerfile. But perhaps the median user would prefer a solution that makes imports just work as expected.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants