Search code examples
graph-tool

graph-tool (docker): no module name 'ipython_genutils'


I am trying to install and run graph-tool in jupyter notebooks using docker by following the following instructions: https://git.skewed.de/count0/graph-tool/-/wikis/installation-instructions#installing-using-docker

My computer is running windows 10 home.

Steps Taken (on windows command prompt)

  1. run docker pull tiagopeixoto/graph-tool in the windows cmd
  • I successfully pull the docker image
  1. run docker run -p 8888:8888 -p 6006:6006 -it -u user -w /home/user tiagopeixoto/graph-tool bash
  • successfully runs
  1. run jupyter notebook --ip 0.0.0.0
  • I try to run the above command and get the error

Traceback (most recent call last): File "/usr/sbin/jupyter-notebook", line 5, in from notebook.notebookapp import main File "/usr/lib/python3.10/site-packages/notebook/init.py", line 27, in from .nbextensions import install_nbextension File "/usr/lib/python3.10/site-packages/notebook/nbextensions.py", line 20, in from ipython_genutils.py3compat import string_types, cast_unicode_py2 ModuleNotFoundError: No module named 'ipython_genutils'

I've also tried running the same above using docker-machine to create a virtual machine and I the exact same error.

Steps Taken (using docker-machine)

  1. Create a vm in virtualbox: docker-machine create -d virtualbox --virtualbox-memory=4096 --virtualbox-cpu-count=4 --virtualbox-disk-size=40960 --virtualbox-no-vtx-check default (I ran this command in bash)
  2. open the command line of the vm from virtualbox and run docker pull tiagopeixoto/graph-tool
  • I successfully pull the docker image
  1. run docker run -p 8888:8888 -p 6006:6006 -it -u user -w /home/user tiagopeixoto/graph-tool bash from the vm (virtualbox) cmd
  • successfully runs
  1. run jupyter notebook --ip 0.0.0.0
  • I try to run the above command and get the error (same error as above)

Traceback (most recent call last): File "/usr/sbin/jupyter-notebook", line 5, in from notebook.notebookapp import main File "/usr/lib/python3.10/site-packages/notebook/init.py", line 27, in from .nbextensions import install_nbextension File "/usr/lib/python3.10/site-packages/notebook/nbextensions.py", line 20, in from ipython_genutils.py3compat import string_types, cast_unicode_py2 ModuleNotFoundError: No module named 'ipython_genutils'

In the virtual machine I also tried installing pip then installing ipython_genutils using the following commands. ipython_genutils successfully installs but I still get the same error as above.

tce-load -wi python3.7

curl https://bootstrap.pypa.io/get-pip.py | sudo python3 -

pip install ipython_genutils

Anyone have any idea how I can fix this error?


Solution

  • I just ran into this issue and came up with this workaround for anyone who may be stuck. Please note I am new to Docker and Linux so there may be better methods/practices but this worked for me!

    First I ran the image as root rather than "user".

    docker run -p 8888:8888 -p 6006:6006 -it -u root -w /home/user tiagopeixoto/graph-tool bash
    

    Then I needed to manually install pip as it is not present in the container.

    pacman -S python-pip
    

    Running a quick pip list confirms that package ipython_genutils is not present. Googling the error message, I was initially lead to this page: https://github.com/ipython/ipython_genutils/issues/3 Which first suggests installing jupyter using pip, which will pull ipython_genutils.

    pip install jupyter
    

    Running pip list now shows ipython-genutils. After this, I believe it is good practice in Docker to use limited-perms user accounts, so I switch back to "user" before continuing the tutorial with su user. Now I am able to successfully continue and launch the Jupyter server without error.

    jupyter notebook --ip 0.0.0.0