Characters typed in response to an `input` prompt are treated in command mode

I use Jupyter a lot when teaching, both for myself and for my students. It’s not unusual for me to have them use the input function to have Python ask them to enter their name. For example:

name = input('What is your name? ').strip()
print(f'Hello, {name}!'

As of several months ago, I’ve found that when I run this code, it works fine on the Python end. But as I type a solution, each character is interpreted as if it were in command mode. So if I type a, it adds a new cell above the current one, and if I type a b, it adds a new cell below the current one.

The only solution I’ve found is to (a) click inside of the input text box and (b) avoid any Jupyter keyboard shortcut characters.

Maybe I accidentally turned a particular feature on or off? I don’t think so, but maybe?

Here’s what I get from running jupyter --version:

Selected Jupyter core packages...
IPython          : 8.20.0
ipykernel        : 6.28.0
ipywidgets       : 8.1.2
jupyter_client   : 8.6.0
jupyter_core     : 5.7.1
jupyter_server   : 2.12.4
jupyterlab       : 4.1.6
nbclient         : 0.9.0
nbconvert        : 7.14.1
nbformat         : 5.9.2
notebook         : 7.1.0
qtconsole        : 5.5.1
traitlets        : 5.14.1

Any thoughts?

I cannot recreate the behaviour in jupyterlab 4.1.6.

It might be worth a try to backup your settings and test if the behaviour persists with default settings.
If this doesn’t help I’d start looking at installed extensions which might cause the problem.

1 Like

The problem doesn’t occur in JupyterLab, only in Notebook. And it occurs in both Firefox and Chrome. I just removed everything I could possibly find having to do with Jupyter on my system, then installed just Jupyter. I started up jupyter notebook, and I again have this problem.

It’s nice to know that the issue doesn’t occur in JupyterLab, so I’ll just use that. But it’s super frustrating not to be able to type into inbox boxes.

I’m sharing a screen capture I made of trying to enter my name (“Reuven”) in response to a text inbox box. R changes the notebook’s layout, e and u are entered fine, and v pastes the most recently cut cell (from before I recorded). Then the cursor focus is lost.

CleanShot 2024-04-25 at 13.06.09

This is the problem. This bug was fixed in a later point release. The latest version is 7.1.3

2 Likes

OMG, I feel so dumb – I used pip install -U on everything except for the notebook package. I totally forgot it wasn’t called jupyter-notebook, so it didn’t show up in my grep from pip freeze.

Thanks so much!

1 Like