I’ve recently been struggling trying to help someone run some notebooks against a Python kernel with a range of Python package dependencies.
They’re on a Windows box — I’m not — and have had a range of issues:
repo2docker didn’t work ( (return os.geteuid() AttributeError: module 'os' has no attribute 'geteuid'?);
Docker didn’t work using a container I prebuilt (how do you reliably mount the current directory against a Docker volume?!);
installing packages didn’t work / couldn’t be found (I have no idea what environmental catastrophe was going on!).
There was a preference for not working on a public machine (so no Binderhub and uploading notebooks there) and we don’t have an internal JupyterHub or BinderHub server.
Which got me thinking. Is there a way of simply packaging a Python kernel with custom packages preinstalled so that it can be shared?
For example, installing the kernel might do something like:
make sure env support is available;
create a new py env;
install the required packages;
register that env as a new, custom-named Jupyter kernel in an existing Jupyter supporting environment.
Or perhaps rather than something like having a binder folder in a directory and running repo2docker, having a kernel directory containing a requirements.txt and running jupyter addkernel --name myPykernel . ?
“Packaging” is a pretty broad problem! While we’d love to solve this for the general case, Jupyter serves many languages and platforms, and each of them (and their combinations) have their own idiosyncrasies.
For the julia-python-r-and-friends-on-windows case, I personally (and Jupyter, for that matter) can’t really recommend anything more heartily than conda (with conda-forge), and an environment.yml.
# environment.yml
name: my-project-env
channels:
- conda-forge
- defaults
dependencies:
- python =3.7 # pip cannot do this for you
- ipykernel
- some-other-package
- pip:
- some-pip-package-not-in-conda
… or you can check these into version control, put them on a shared drive, whatever. Just don’t actually check in your environment!
If you need to go really offline, you can put miniconda, and the downloaded results of conda list --explicit on a thumb drive, and reconstitute your environment without any internet at all.
For more advanced use cases, you can try anaconda-project which goes one further and lets you lock/unlock cross-platform environments.
I guess in the py case I could script something like https://janakiev.com/blog/jupyter-virtual-envs/ (which was my immediate concern) but for other kernels they’d need an equivalent environment mechanism.
@betatim If Kitematic / containds work properly on WIndows, then yes?! Certainly, the directory mapping from host into a container is handled via file selection dialogues, so hopefully any case issues in the path names are robustly handled by the app (which they donlt appear to be on the docker cli?)