In the past I have struggled getting Jupyter notebook to run with virtualenv or by installing Anaconda directly. Recently I found a few docker images that make it really easy!
At https://github.com/jupyter/docker-stacks there are a number of different notebooks configurations available, I decided to use the datascience-notebook configuration for this example, but the other notebook configurations should have similar setup.
First you must have docker installed. I recommend docker-machine for Windows and Mac machines or installing docker directly on Linux based machines.
Simply run:
sudo docker run -it --rm -p 8888:8888 jupyter/datascience-notebook
The first run will take a while to download the necessary images, but when it is running you should see some text like:
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=13924b42353bb9bf49e4e837956ba3712cea40b7c252a48c
Follow that link and you are in! There is one important added step, which is notebook persistence. With the above configuration all of your notebooks will disappear when the docker instance is stopped. We must mount a volume locally to save our notebooks.
Instead Run:
sudo docker run -it --rm -v YOUR_DIRECTORY:/home/jovyan/work/notebooks -p 8888:8888 jupyter/datascience-notebook
Now all notebooks saved in the work/notebooks folder will appear in YOUR_DIRECTORY. There can be a number of permissions errors with this configuration, but they are operating system specific and beyond the scope of this post.
I hope you enjoy not having to struggle with installing and updating Jupyter as much as me!
Leave a Reply