[英]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.