简体   繁体   English

使用 IPython display(markdown()) 后未显示 Jupyter notebook input()

[英]Jupyter notebook input() not showing after using IPython display(markdown())

I am trying to build a Chatbot using Jupyter Notebook on Google Colab.我正在尝试在 Google Colab 上使用 Jupyter Notebook 构建聊天机器人。 I am using IPython Markdown to better segregate the user conversations.我正在使用 IPython Markdown 来更好地隔离用户对话。 User will key in their message using input() while the bot responses are IPython display(markdown()) .用户将使用input()键入他们的消息,而机器人响应是 IPython display(markdown())

I am facing issues when i tried to print a starting messages (bot output before a user input).当我尝试打印起始消息(用户输入之前的机器人输出)时,我遇到了问题。 This error occurs approximately 50% of the time I run the script.大约 50% 的时间我运行脚本时会发生此错误。 No errors are faced if I did not print out the starting message.如果我没有打印出起始消息,就不会出现错误。 I have tried restarting the kernel but to no avail.我试过重新启动内核,但无济于事。

Does anyone know what is the reason for this and how I can fix it?有谁知道这是什么原因以及我该如何解决?

This is an example of a successful case.这是一个成功案例。 成功案例

This is an example of a failed case.这是一个失败的案例。 As you can see, the code is running indefinitely on the input() line.如您所见,代码在input()行上无限期地运行。 加载失败

This is the sample code, where input() box does not pop up at times.这是示例代码,其中input()框有时不会弹出。

from IPython.display import Markdown, display

display(Markdown("*Alex:* Hello."))

input(">> You: ")

This seems to be a kind of bug in Jupyter notebook, described along last years by many programmers.这似乎是 Jupyter Notebook 中的一种错误,许多程序员在去年都有描述。 I was facing the same problem.我面临同样的问题。 After several tests I have found (at least in my code) that the problem disappear if print() functions are removed before input().经过几次测试后,我发现(至少在我的代码中)如果在 input() 之前删除 print() 函数,问题就会消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ipython.display.display 在 Jupyter Notebook 中不显示图像 - ipython.display.display not showing image in Jupyter Notebook Jupyter / IPython Notebook 文本编辑为 Markdown - Jupyter / IPython Notebook text editing as markdown jupyter notebook ipython 小部件显示为文本 - jupyter notebook ipython widgets display as text 在 Jupyter Notebook 中使用 Ipython 显示加载多个图像 - Loading multiple images with Ipython display in Jupyter Notebook 如何在 Markdown for IPython Notebook (Jupyter) 中并排包含两张图片? - How to include two pictures side by side in Markdown for IPython Notebook (Jupyter)? Pycharm Jupyter笔记本Markdown显示模糊字体 - Pycharm Jupyter Notebook Markdown Display Fuzzy Font 在 Ipython 中使用 Pylint (Jupyter-Notebook) - Using Pylint in Ipython (Jupyter-Notebook) 在Jupyter iPython Notebook中使用matplotlib绘制图形 - Plotting graph using matplotlib in Jupyter iPython Notebook 使用 IPython.display.audio 在 function 中使用时无法在 jupyter notebook 中播放音频 - Using IPython.display.audio to play audio in jupyter notebook not working when used inside a function 在Jupyter Notebook中使用Pandas表的IPython.display时如何在单元格周围包含边框 - How to include border around cells when using IPython.display of Pandas table in Jupyter Notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM