简体   繁体   English

IPython Notebook中的[*]是什么意思以及如何将其关闭?

[英]What does In [*] in IPython Notebook mean and how to turn it off?

I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1. 我使用Windows 7,Python 2.7.9加上最新版本的IPython 3.1。

I ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. 我在IPython Notebook中运行%python并运行单元格,而不是返回Python版本,它没有运行并跳转到新行并打印In [*]而不是行号。 Now no line is running in ipython everything is ignored when I try to run a cell value. 现在ipython中没有运行任何行,当我尝试运行单元格值时,所有内容都被忽略。

Anyone know what has happen? 谁知道发生了什么?

The kernel is busy. 内核很忙。 Go to the menu Kernel and click Interrupt . 转到菜单Kernel ,然后单击Interrupt If this does not work click Restart . 如果这不起作用,请单击“ Restart You need to go in a new cell and press Shift + Enter to see if it worked. 您需要进入一个新单元格并按Shift + Enter查看它是否有效。

The issue causing your kernel to be busy can be a specific line of code. 导致内核繁忙的问题可能是特定的代码行。 If that is the case, your computer may just need time to work through that line. 如果是这种情况,您的计算机可能只需要时间来完成该行。

To find out which line or lines are taking so long, as mentioned by Mike Muller you need to restart the program or interrupt the kernel. 要找出需要这么长时间的线路,正如Mike Muller所提到的,您需要重新启动程序或中断内核。 Then go through carefully running one line at a time until you reach the first one with the asterisk. 然后一次仔细地运行一行,直到你用星号到达第一行。

If you do not restart or interrupt your busy program, you will not be able to tell which line is the problem line and which line is not, because it will just stay busy while it works on that problem line. 如果您没有重新启动或中断繁忙的程序,您将无法分辨出哪一行是问题行,哪一行不是,因为它会在该问题行上工作时保持忙碌状态。 It will continue to give you the asterisk on every line until it finishes running that one line of code even if you start back at the beginning. 它将继续在每一行上给你一个星号,直到它完成运行那一行代码,即使你在开头回来。 This is extremely confusing, because lines that have run and produced output suddenly lose their output when you run them on the second pass. 这非常令人困惑,因为当你在第二遍中运行它们时,已经运行并产生输出的行会突然失去输出。 Also confusing is the fact that you can make changes to your code while the kernel is busy, but you just can't get any new output until it is free again. 令人困惑的是,您可以在内核繁忙时对代码进行更改,但在再次释放之前,您无法获得任何新输出。

Your code does not have to be wrong to cause this. 您的代码不一定是错误的原因。 You may just have included a time-consuming command. 您可能只是包含了一个耗时的命令。 Bootstrapping has caused this for me. Bootstrapping给我带来了这个。

If your code is what it needs to be, it doesn't actually matter which line is the problem line, and you just need to give all of your code time to run. 如果您的代码是它所需要的,那么问题行的哪一行实际上并不重要,您只需要花费所有代码时间来运行。 The main reasons to find out which is the problem line would be if some lines were expendable, or in case you were getting the asterisk for some other reason and needed to rule this one out. 找出哪个是问题线的主要原因是,如果某些线路是可消耗的,或者如果你因某些其他原因得到星号而需要对此进行排除。

If you are writing code on an internet service that times out when you aren't giving it input, your code might not have enough time to finish running if you just wait on it. 如果您在互联网服务上编写的代码在您没有输入时超时,那么您的代码可能没有足够的时间来完成运行,如果您只是等待它。 Scrolling every few minutes is usually enough to keep those pages from timing out. 每隔几分钟滚动一次就足以防止这些页面超时。

为了解决这个问题,我不得不停止我的反病毒程序。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM