Jupyter with docker: __init__() got an unexpected keyword argument 'column'

Viewed 1043

I recently installed TensorFlow with GPU support using docker:

docker pull tensorflow/tensorflow:latest-gpu-jupyter

But sometimes when I start a jupyter notebook server using the command:

docker run --gpus all -it -p 8888:8888 tensorflow/tensorflow:latest-gpu-jupyter jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --allow-root --NotebookApp.allow_origin='https://colab.research.google.com'

I see the following exception on the terminal:

[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 272, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 762, in run
    value = future.result()
  File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 234, in wrapper
    yielded = ctx_run(next, result)
  File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 162, in _fake_ctx_run
    return f(*args, **kw)
  File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 580, in complete_request
    matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
  File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 348, in do_complete
    return self._experimental_do_complete(code, cursor_pos)
  File "/usr/local/lib/python3.6/dist-packages/ipykernel/ipkernel.py", line 373, in _experimental_do_complete
    completions = list(_rectify_completions(code, raw_completions))
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 484, in rectify_completions
    completions = list(completions)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 1818, in completions
    for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 1862, in _completions
    full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 2030, in _complete
    cursor_pos, cursor_line, full_text)
  File "/usr/local/lib/python3.6/dist-packages/IPython/core/completer.py", line 1374, in _jedi_matches
    text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
  File "/usr/local/lib/python3.6/dist-packages/jedi/api/__init__.py", line 726, in __init__
    project=Project(Path.cwd()), **kwds)
TypeError: __init__() got an unexpected keyword argument 'column'

After that, I have to restart the server or reconnect from google colab.

Any ideas where the error might come from and how to fix it?

2 Answers

This seems to be an incompatibility between jedi and ipython, see this issue.

The fix would be to pin jedi to 0.17.2, so either run:

pip install jedi==0.17.2

Or if you are using poetry add this to your pyproject.toml:

jedi = "<=0.17.2"

But since you are using a docker image that image will need to be updated. It seems to be gpu-jupyter.Dockerfile.

I would raise an issue on that project and see if they can pin jedi like they did for nbformat, or you could just fork it. They should probably upgrade python as well, 3.6 is getting a bit long in the tooth.

I will add more details to @daphtdazz's answer. I had to do the following steps to solve this issue:

1. Download TensorFlow from github:

git clone https://github.com/tensorflow/tensorflow.git

2. Edit the file gpu-jupyter.Dockerfile to add jedi==0.17.2 at the end of line 104:

vim tensorflow/tensorflow/tools/dockerfiles/dockerfiles/gpu-jupyter.Dockerfile 

3. Placed myself inside the dockerfiles folder :

cd tensorflow/tensorflow/tools/dockerfiles/

4. Build the image:

docker build -f ./dockerfiles/gpu-jupyter.Dockerfile -t tf .
Related