Ivan Ivan - 1 year ago 511
Python Question

Import pandas on docker with tensorflow

I am using Windows and learning to use tensorflow, so I need to run it under Docker (Toolbox).

Following the usual instruction:

$ docker run -it gcr.io/tensorflow/tensorflow


I can launch a Jupyter notebook on my browser at
192.168.99.100:8888
and run the tutorial notebooks without problems.

Now when I try to
import pandas as pd
, which is installed in my computer with pip, on Juypter it just said
ImportError: No module named pandas


Any idea how I can get this library to work inside the tensorflow images launched from docker?

Screenshot

Answer Source

The Docker image should be built on a linux operating system. You should launch a shell inside the Docker image grc.io/tensorflow/tensorflow to install the requisite python dependencies.

See Docker quickstart for using

docker run -it grc.io/tensorflow/tensorflow /bin/bash

and then

sudo apt-get install python-pandas

according to pandas docs.

To avoid doing this every time you launch the image, you need to commit the change to create a new image.

To commit the change, you need to get the container id (after run and installation steps above):

sudo docker ps –a # Get list of all containers previously started with run command

Then, commit your changes git style using the container_id displayed in the container list you just got and giving it an image_name of your choosing:

sudo docker commit container_id image_name 

The new image will now show up in the list displayed by sudo docker ps –a.

If you get a free docker account you can push and pull your updated image to your docker repo, or just keep it locally.

See docs under 'Updating and Committing your image'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download