Run IPython notebook in docker container on ubuntu16


I am trying to create a docker container to tun ipython notebook.

I have tried using docker-notebook image.

The problem is:

Even though I have mentioned all the dependencies in Dockerfile and it installs all the dependencies during the build, but when the ipython server is launched and after creating a new notebook, i get "ImportError: no module named ‘pandas’ found.

Things i have tried:

  • 1.docker exec sudo apt-get install pandas [Doesnt work]

  • 2.laucnhing bib/bsh of container: docker run bin/bash

  • 2.1.and installing inside bin/bash: sudo apt-get install pandas OR pip install pandas [Doesnt work]

  • 3.Commiting the container after making changes [YES it works,changes are preserved] BUT i cannot run the newly commited container because it launches the bin/bash where as i need ipython server.

I have also tried the git repo: ipython/ipython:

  • It throws the error that: No runnable webbrowser found.
    I checked in container using bin/bash, the file has no entry of c.NotebookApp.browser.
    How can i fix this in Dockerfile? Because i cannot fix it using boin/bash as all the changes are lost when I exit the container.

you could try this one. I’m using it and it works for me. You can check the Dockerfile to see how I got it to work.

Pandas is not installed. If you want to install pandas, you just could execute:

    apk update &&
    apk add libpng-dev freetype-dev &&
    ln -s /usr/include/locale.h /usr/include/xlocale.h &&
    pip3 install matplotlib pandas numpy

Normally I just sometimes need pandas, so I’m happy enough to install pandas in a notebook-shell step, once the notebook requires it.

I will try this solution and let you know. Thanks so much :slight_smile:
Have you tried importing pandas in ipython notebook after running this container ? @think

yes. did yesterday some histograms with pandas. So also the inlining of the plot is working.

1 Like

oh thats great! :slight_smile: can you post your docker file please? @think

just check out the dockerhub link above…you will find everything there, including the link to github with even more details

I checked the Dockerfile. These line you provided above

apk update &&
    apk add libpng-dev freetype-dev &&
    ln -s /usr/include/locale.h /usr/include/xlocale.h &&

arent in the dockerfile. You added these above lines to install pandas numy & matplotlib? @think

I have added line pip3 install pandas matplotlib numpy. but it throws a very long error when collecting pandas :frowning:

i do not deploy pandas in my notebook by default. I just have it as notebook shell-cell if one notebook needs it.

apk update ....

could show me your error message? your Dockerfile?

its a very long error, “something not found in locale.h”. Anyway, i got it. Thnaks alot :slight_smile: its working fine now.

Can you please tell me what this shell-cell is? can we install any library on the run using this shel-thing inside notebook cells?

yes, you could, you besically just add in your notebook a new cell.
instead of python, you write

ps -Af

this lets you execute everything you want.
Also install new plugins / tools / …