0

I've been running a script on jupyter notebook:

num=input("Enter a number: ")
print(num)

When i run this cell, nothing is printing in output cell, no text box is appearing. It simply passes on to new cell. Initially when I ran it for the first time, the notebook gave "'_xsrf' argument missing from post" error which i resolved by opening another notebook as referred in Jupyter Notebook not saving: '_xsrf' argument missing from post. The autosave problem was resolved but it still ain't printing anything. My python version is 3.9.7.

  • 3
    This looks like a Jupyter issue rather than a Python problem *per se* – DarkKnight Apr 22 '22 at 12:07
  • Can you try creating and putting this code in a new cell? And if it works, delete the first cell. – Floh Apr 22 '22 at 12:08
  • I tried this but yet not getting any output, Also i just noticed another problem and i agree with @LancelotduLac that there's a notebook problem : i mistakenly wrote print as ptint , yet the cell ran and didn't give any error, although autosave and save options are working – Sneha Kumari Apr 22 '22 at 12:12
  • Does `print()` in a cell alone work? Is Jupyter installed locally or are using using it via website? I ask because a lot of people are trying to use `input()` with JupyterLite, not realizing that won't work. If local Jupyter, did you install it recently or was it already there and you updated Python? I ask that because you list your Python version as very recent, but nothing about Jupyter. Are you using Anaconda? Are you on a Windows or Mac machine? – Wayne Apr 22 '22 at 15:57
  • Yes, @Wayne print() in a cell does work alone. I have Jupyter notebook pre-installed locally( it runs on localhost). I am not using JupyterLite. I installed anaconda 3 months back ig and jupyter notebook was already there with it. Also i haven't updated Python since then. I am using Windows 10. – Sneha Kumari Apr 22 '22 at 17:00
  • 1
    Following on @Floh's suggestion, if you make an entirely new notebook and paste in that code, does it work? You are using the classic notebook interface and not JupyterLab? – Wayne Apr 22 '22 at 17:37
  • Yep, in entirely new notebook it is working, infact i saved and opened the same code again, it worked. But back when it happened, it stayed stuck for hours, and in the original notebook itself, i tried creating new cell and doing same thing , it was still behaving the same way. Maybe there was a bug with the notebook. No I am not using JupyterLab. – Sneha Kumari Apr 22 '22 at 18:02
  • 1
    Okay, at least you see the way around it now. When it was stuck, nothing worked, or just `input()` didn't work? If nothing worked, then it was the kernel connection getting messed up. If `print()` worked and not `input()` then it would seem something got botched when that `input()` was run and became blocking for a new input. It definitely all seems consistent with [that link](https://stackoverflow.com/questions/55014094/jupyter-notebook-not-saving-xsrf-argument-missing-from-post/55601395#55601395?newreg=55c1966baa4e4c94accf7f2f31100185) you referenced since a new notebook fixes it. – Wayne Apr 22 '22 at 18:10

0 Answers0