Description
openedon Nov 30, 2023
Description
When running jupyter console
from the terminal and entering the pdb (ipdb) debugger, arrow keys and and other keys are not interpreted correctly. I've tried to find a fix for this and have not found anything.
Reproduce
To reproduce, I'll show a difference between the correct behavior when running using ipython
and incorrect behavior within jupyter console
.
- Create and activate a fresh virtualenv using python3.9 (same behavior occurs with python3.11)
pip install jupyter
ipython works as expected
- Start ipython, create an exception, and drop into pdb using the
%debug
magic line:
$ ipython
Python 3.9.18 (main, Aug 24 2023, 21:20:15)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.18.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: assert False
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[1], line 1
----> 1 assert False
AssertionError:
In [2]: %debug
> <ipython-input-1-a871fdc9ebee>(1)<module>()
----> 1 assert False
ipdb>
- Now, at the ipdb prompt, type a few letters and then push the left arrow key. Exact keystrokes:
asdf<left arrow><left arrow>
. The cursor moves back as expected:
jupyter console does not work as expected
- Start jupyter console, create an exception, and drop into pdb using the
%debug
magic line:
$ jupyter console
Jupyter console 6.6.3
Python 3.9.18 (main, Aug 24 2023, 21:20:15)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.18.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: assert False
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[1], line 1
----> 1 assert False
AssertionError:
In [2]: %debug
> /var/folders/55/z__ff1rx7tq84rxr_62wls780000gn/T/ipykernel_24856/2103537015.py(1)<module>()
----> 1 assert False
ipdb>
- Now, at the ipdb prompt, type a few letters and then push the left arrow key. Exact keystrokes:
asdf<left arrow><left arrow>
. The arrow keys are misinterpretted as^[[D
:
- Other
readline
style keys that usually work also fail here, e.g.C-a
to go to the beginning of the line works inipython
but does not injupyter console
.
Expected behavior
Expected: arrow keys that work correctly within ipython
would also work within jupyter console
.
Actual: jupyter console
misinterprets arrow keys.
Context
- Operating System and version: MacOS Ventural 13.6
- Browser and version: N/A
- Jupyter Notebook version:
$ jupyter --version
Selected Jupyter core packages...
IPython : 8.18.1
ipykernel : 6.27.1
ipywidgets : 8.1.1
jupyter_client : 8.6.0
jupyter_core : 5.5.0
jupyter_server : 2.11.1
jupyterlab : 4.0.9
nbclient : 0.9.0
nbconvert : 7.11.0
nbformat : 5.9.2
notebook : 7.0.6
qtconsole : 5.5.1
traitlets : 5.14.0
Troubleshoot Output
$ jupyter troubleshoot $PATH: /Users/jason/virtualenvs/jup_bug/bin /Users/jason/local/sbin /Users/jason/local/bin /opt/homebrew/bin /opt/homebrew/sbin /opt/homebrew/opt/python@3.9/libexec/bin /opt/homebrew/opt/coreutils/libexec/gnubin /usr/local/bin /usr/local/sbin /usr/local/cuda/bin /usr/bin /bin /usr/sbin /sbin /opt/X11/bin /Library/TeX/texbinsys.path:
/Users/jason/virtualenvs/jup_bug/bin
/Users/jason
/opt/homebrew/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python39.zip
/opt/homebrew/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9
/opt/homebrew/Cellar/python@3.9/3.9.18/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload
/Users/jason/virtualenvs/jup_bug/lib/python3.9/site-packagessys.executable:
/Users/jason/virtualenvs/jup_bug/bin/pythonsys.version:
3.9.18 (main, Aug 24 2023, 21:20:15)
[Clang 14.0.0 (clang-1400.0.29.202)]platform.platform():
macOS-13.6-arm64-arm-64bitwhich -a jupyter:
/Users/jason/virtualenvs/jup_bug/bin/jupyterpip list:
Package Version
------------------------- ----------
anyio 4.1.0
appnope 0.1.3
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 2.4.1
async-lru 2.0.4
attrs 23.1.0
Babel 2.13.1
beautifulsoup4 4.12.2
bleach 6.1.0
certifi 2023.11.17
cffi 1.16.0
charset-normalizer 3.3.2
comm 0.2.0
debugpy 1.8.0
decorator 5.1.1
defusedxml 0.7.1
exceptiongroup 1.2.0
executing 2.0.1
fastjsonschema 2.19.0
fqdn 1.5.1
idna 3.6
importlib-metadata 6.8.0
ipykernel 6.27.1
ipython 8.18.1
ipywidgets 8.1.1
isoduration 20.11.0
jedi 0.19.1
Jinja2 3.1.2
json5 0.9.14
jsonpointer 2.4
jsonschema 4.20.0
jsonschema-specifications 2023.11.2
jupyter 1.0.0
jupyter_client 8.6.0
jupyter-console 6.6.3
jupyter_core 5.5.0
jupyter-events 0.9.0
jupyter-lsp 2.2.1
jupyter_server 2.11.1
jupyter_server_terminals 0.4.4
jupyterlab 4.0.9
jupyterlab_pygments 0.3.0
jupyterlab_server 2.25.2
jupyterlab-widgets 3.0.9
MarkupSafe 2.1.3
matplotlib-inline 0.1.6
mistune 3.0.2
nbclient 0.9.0
nbconvert 7.11.0
nbformat 5.9.2
nest-asyncio 1.5.8
notebook 7.0.6
notebook_shim 0.2.3
overrides 7.4.0
packaging 23.2
pandocfilters 1.5.0
parso 0.8.3
pexpect 4.9.0
pip 23.3.1
platformdirs 4.0.0
prometheus-client 0.19.0
prompt-toolkit 3.0.41
psutil 5.9.6
ptyprocess 0.7.0
pure-eval 0.2.2
pycparser 2.21
Pygments 2.17.2
python-dateutil 2.8.2
python-json-logger 2.0.7
PyYAML 6.0.1
pyzmq 25.1.1
qtconsole 5.5.1
QtPy 2.4.1
referencing 0.31.1
requests 2.31.0
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.13.2
Send2Trash 1.8.2
setuptools 68.2.2
six 1.16.0
sniffio 1.3.0
soupsieve 2.5
stack-data 0.6.3
terminado 0.18.0
tinycss2 1.2.1
tomli 2.0.1
tornado 6.4
traitlets 5.14.0
types-python-dateutil 2.8.19.14
typing_extensions 4.8.0
uri-template 1.3.0
urllib3 2.1.0
wcwidth 0.2.12
webcolors 1.13
webencodings 0.5.1
websocket-client 1.6.4
wheel 0.41.3
widgetsnbextension 4.0.9
zipp 3.17.0
Command Line Output
(Body of this post was too long, so I have instead included this output in a comment below)
Browser Output
I think this is not applicable.
Activity