在PyQ内核重新启动之前,笔记本电脑单元在第一个错误后不会运行

时间:2018-12-12 09:04:49

标签: jupyter-notebook kdb pyq

我正在运行具有PyQ内核的jupyter笔记本,并且能够同时运行python和q代码。但是:只要单元产生错误(例如调用nonexisting_function()),在我重新启动内核之前,将不再执行任何单元。相比之下,使用Python内核,我也可以在发生错误后运行其他(或相同)单元,这被认为是正常行为。
enter image description here 我在64位ubuntu上将miniconda3与虚拟环境(mypyq)一起使用。

(mypyq) user@workstation:~$ conda --version
conda 4.5.11
(mypyq) user@workstation:~$ conda list
# packages in environment at /home/user/miniconda3/envs/mypyq:
#
# Name                    Version                   Build  Channel
<lines skipped>
kdb                       3.6                  2018.10.23    kx
pyq                       4.1.4            py36h39e3cac_0    enlnt
pyq-kernel                1.0                       <pip>
python                    3.6.7                h0371630_0  
(mypyq) user@workstation:~$ jupyter notebook --debug
<lines skipped>

在笔记本中运行6*7

[D 09:37:54.476 NotebookApp] activity on ...: status
[D 09:37:54.476 NotebookApp] activity on ...: execute_input
[D 09:37:54.477 NotebookApp] activity on ...: execute_result
[D 09:37:54.479 NotebookApp] activity on ...: status

单元格输出为42,到目前为止一切正常。

现在在笔记本中运行nonexisting()

[D 09:38:38.266 NotebookApp] activity on ...: status
[D 09:38:38.267 NotebookApp] activity on ...: execute_input
[D 09:38:38.315 NotebookApp] activity on ...: error
[D 09:38:38.317 NotebookApp] activity on ...: status

笔记本单元格输出:

------------------------------------
NameError   Traceback (most recent call last)
<ipython-input-2-124a31d9d771> in <module>
----> 1 nonexisting()

NameError: name 'nonexisting' is not defined

再次运行6*7单元:

[D 09:39:29.799 NotebookApp] activity on ...: status
[D 09:39:29.799 NotebookApp] activity on ...: status

我在控制台中至少缺少...: execute_result。在重新启动内核之前,笔记本中也没有任何输出。

仅在PyQ内核中,这在Python内核中不会发生。在控制台中运行PyQ也可以:

(mypyq) user@workstation:~$ pyq
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:19:38) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> q('9#til 3')
k('0 1 2 0 1 2 0 1 2')
>>> nonexisting()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'nonexisting' is not defined
>>> 6*7
42
>>> exit()

IPython也可以:

(mypyq) user@workstation:~$ pyq -m IPython
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:19:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %load_ext pyq.magic                                                                                                          

In [2]: from pyq import q                                                                                                            

In [3]: q.til(10)                                                                                                                    
Out[3]: 0 1 2 3 4 5 6 7 8 9

In [4]: nonexisting()                                                                                                                
-------------------------------------------------------
NameError             Traceback (most recent call last)
<ipython-input-4-124a31d9d771> in <module>
----> 1 nonexisting()

NameError: name 'nonexisting' is not defined

In [5]: q.til(10)                                                                                                                    
Out[5]: 0 1 2 3 4 5 6 7 8 9

In [6]: exit()

运行错误的单元后,当我使用Ctrl-C关闭jupyter笔记本服务器时,它将报告超时并杀死内核。

Shutdown this notebook server (y/[n])? y
[C 11:03:05.086 NotebookApp] Shutdown confirmed
[I 11:03:05.086 NotebookApp] Shutting down 1 kernel
[D 11:03:10.100 NotebookApp] Kernel is taking too long to finish, killing
[I 11:03:10.106 NotebookApp] Kernel shutdown:

1 个答案:

答案 0 :(得分:1)

此错误已在pyq-kernel 1.0.1, which was recently released中修复。谢谢您的举报。

要升级,请运行:

pip install -U pyq-kernel
pyq -m pyq.kernel install

将来,请随时在PyQ project repository中打开问题,以加快响应速度。