Show question/input in vscode jupyter notebook output
Asked Answered
B

3

12

Is there any way to show input question in cell output while using vscode jupyter notebook? When I use Google Colab, there are question in the cell output. I want to know how to show question without using print().

In google Colab: https://i.sstatic.net/L71OS.png

In vsCode: https://i.sstatic.net/4szQJ.png

Blayze answered 14/10, 2020 at 9:45 Comment(2)
This question bubbled up four years later because some others are posting updates here and on other related threads on SO, and so I'll point out that I suspect the original poster was looking for more rich abilities to make user interfaces in what seems like the output area in a notebook, like you can seem to do with Voila and other software you can use to make apps out of notebooks. input() would not be the way to go about that as it was made long ago for text-only interfaces before IPython Noteboook, which pre-date Jupyter. Users looking to do tings like this in current Jupyter ...Nickynico
<continued> are probably looking for more modern user interfaces you can make using ipywidgets and Solara. Those work in notebooks as well as the web apps based on notebooks that you'll come across looking into Voila or Solara apps, plus there's the frameworks like Ploty Dash and Panel, etc. that operate in this area and work in Jupyter, too.Nickynico
R
9

At present, the Jupyter function in VSCode is provided by Python extension. The bottom of each cell is used to display output. Therefore, the input it receives is provided by the input box above, which is its display input mode.

enter image description here

If you want to display input and output in the same place, it is recommended that you use a python file, and the terminal will display the input and output content in turn.

enter image description here

Runic answered 15/10, 2020 at 2:35 Comment(2)
So is there are no way to disable input box in VSCode Jupyter?Blayze
@Blayze -Yes, currently, the input of Jupyter in VSCode is here and here is the integrated design. This is an important input channel, we better not disable it.Runic
E
1

When using jupyter notebook with a code requesting an input, the input shows up as a pop up at the top of the screen. See description in the picture, as for a first time user it could be difficult to catch.enter image description here

Erumpent answered 18/6 at 7:10 Comment(1)
this never popped up for me lol. is there any additional config that needs to be set after installing the vscode extension?Urumchi
M
0

You may substitute builtins input by your own function

import builtins
def input(prompt):
    x = builtins.input(prompt)
    print(prompt+x)
    return x
Morgan answered 17/12, 2023 at 21:9 Comment(1)
this example appears incomplete. It does nothing.Xylophagous

© 2022 - 2024 — McMap. All rights reserved.