Jupyter Converts Code Cell with input() into Markdown with Comments

I’m encountering a strange issue in Jupyter Notebook when trying to use the input() function in my code cells. When I run the following code:
a = int(input("Enter a number: "))
print(a)
Instead of executing the code normally, Jupyter converts the cell into a Markdown cell and adds comments to the code like this:

### a = int(input("Enter a number: "))
print(a)

It doesn’t allow me to provide input, and the kernel shows a message like:

css

Copy code

Cell not executed due to pending input.
The cell has not been executed to avoid kernel deadlock as there is another pending input.

What I’ve Tried:

  • Restarting the kernel and re-running the code.
  • Ensuring that the cell is in “Code” mode (not Markdown).
  • Disabling extensions.
  • Reinstalling Jupyter Notebook.

None of these steps seem to resolve the issue. It keeps happening with every code cell that uses input().

System Info:

  • Jupyter Notebook (latest version)
  • Windows 10
  • Running in Anaconda environment

Help Needed:

Has anyone else faced this issue? Is there a fix or a configuration I might be missing? Any help would be appreciated!


It sounds like this covered in ‘Int(input()) command not working on jupyter notebook’ and in ‘Notebook does not accept user input’.
That help?

Jupyter Notebook (latest version)

Can you post the exact version displayed in the help menu?

1 Like