jupyter / jupyter/notebook

Tab completion not working

Open
#4,418 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

For the last few months, I've not been able to tab complete anything in a Python 3.7 Jupyter notebook. To check, I made a fresh installation of conda and made an environment with just jupyter and numpy,
```
TMPDIR=$(mktemp -d)
pushd $TMPDIR
wget "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
chmod 0700 Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -p "$PUT_IT_HERE"
. "$PUT_IT_HERE"/etc/profile.d/conda.sh
popd
rm -rf $TMPDIR
conda activate
conda create -y -n test jupyter numpy
conda activate test
jupyter notebook
```
I make a new notebook, put `import numpy as np` in the first cell, and run it. In the second cell, I type `np.`. Nothing happens and I get the following stack trace in the terminal,
>[I 10:56:18.381 NotebookApp] Serving notebooks from local directory: /home/povey
>[I 10:56:18.381 NotebookApp] The Jupyter Notebook is running at:
>[I 10:56:18.381 NotebookApp] http://localhost:8888/?token=e8c68ad0cb74f0c0a7c1e3141ab40a4998111d26c601bf88
>[I 10:56:18.381 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
>[C 10:56:18.487 NotebookApp]
>
> To access the notebook, open this file in a browser:
file:///run/user/14623/jupyter/nbserver-9035-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=e8c68ad0cb74f0c0a7c1e3141ab40a4998111d26c601bf88
[9049:9049:0222/105618.761618:ERROR:browser_dm_token_storage_linux.cc(101)] Error: /etc/machine-id contains 0 characters (32 were expected).
Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
ATTENTION: default value of option force_s3tc_enable overridden by environment.
[9049:9068:0222/105619.296041:ERROR:browser_process_sub_thread.cc(209)] Waited 3 ms for network service
Opening in existing browser session.
[I 10:56:34.823 NotebookApp] Kernel started: 2cbd586c-c3cd-4b9d-8226-e6313a820c16
[I 10:56:39.970 NotebookApp] Kernel shutdown: 2cbd586c-c3cd-4b9d-8226-e6313a820c16
[I 10:56:40.009 NotebookApp] Kernel started: a9e49ca8-c548-4007-aeaa-32b818aaea7f
[I 10:56:51.097 NotebookApp] Adapting to protocol v5.1 for kernel a9e49ca8-c548-4007-aeaa-32b818aaea7f
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 267, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/tornado/gen.py", line 1133, in run
value = future.result()
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 572, in complete_request
matches = yield gen.maybe_future(self.do_complete(code, cursor_pos))
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/ipykernel/ipkernel.py", line 348, in do_complete
return self._experimental_do_complete(code, cursor_pos)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/ipykernel/ipkernel.py", line 373, in _experimental_do_complete
completions = list(_rectify_completions(code, raw_completions))
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/IPython/core/completer.py", line 485, in rectify_completions
completions = list(completions)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/IPython/core/completer.py", line 1814, in completions
for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/IPython/core/completer.py", line 1858, in _completions
full_text=full_text, cursor_line=cursor_line, cursor_pos=cursor_column)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/IPython/core/completer.py", line 2025, in _complete
cursor_pos, cursor_line, full_text)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/IPython/core/completer.py", line 1369, in _jedi_matches
text[:offset], namespaces, column=cursor_column, line=cursor_line + 1)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/jedi/api/__init__.py", line 429, in __init__
super(Interpreter, self).__init__(source, environment=environment, **kwds)
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/jedi/api/__init__.py", line 102, in __init__
os.path.dirname(self.path)if path else os.getcwd()
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/jedi/api/project.py", line 181, in get_default_project
if _is_django_path(dir):
File "/home/povey/bin/conda3/envs/test/lib/python3.7/site-packages/jedi/api/project.py", line 152, in _is_django_path
with open(os.path.join(directory, 'manage.py'), 'rb') as f:
IsADirectoryError: [Errno 21] Is a directory: '/home/manage.py'

Any idea what I'm doing wrong? I can't find any obvious examples of someone else having this problem.

Contributor guide

Open the contributing guide

Research direction

Reproduce the minimal conda/Jupyter setup, then inspect ipykernel/kernelbase.py, ipykernel/ipkernel.py, IPython/core/completer.py, and jedi/api/project.py at the traceback locations. Confirm that pressing Tab after np. no longer raises IsADirectoryError for /home/manage.py and that completion results are returned normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.