It is convenient to provide an example Jupyter notebook for a new package and add the hooks necessary to run the example with Binder. However, normally the package will not be included in the python path. To do that, one needs a setup.py
for the package (see binder docs). Once this is done, it is possible to import the package in a notebook running within Binder.
# If mypackage isn't included in the python path, then one would need to add it
#import sys
#sys.path.append('..')
But if the repository has a setup.py
binder (repo2docker) will run pip install -e .
.
import mypackage
dir(mypackage)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'core']