博客
关于我
解决jupyter运行pyqt代码内核重启
阅读量:129 次
发布时间:2019-02-27

本文共 611 字,大约阅读时间需要 2 分钟。

在jupyter notebook或者是 Qtconsole下编译运行一个简单的pyqt程序,总是报错:The kernel appears to have died. It will restart automatically.

from PyQt5.QtWidgets import *from PyQt5.QtGui import *from PyQt5.QtCore import *import sysapp = QApplication(sys.argv)window = QWidget();window.show()app.exec_()

这里写图片描述

在网上找了半天原因,终于在一个小角落发现了问题所在。现在记下来。
这是因为jupyter本身也是用pyqt编写的,python同时只能运行一个内核。在上述代码最后一行一下子把内核给停止了,所以就导致了重启。
改成

sys.exit(app.exec_())

这样再运行结束程序是只会结束本程序 不会终止内核 。问题解决。

但是这样也引入了一个新的问题

An exception has occurred, use %tb to see the full traceback

因为这个程序直接调用sys.exit直接终止的 。不过影响不大。

总结:这两个错误都是在IPython交互环境下才会报错,脚本运行时不会报错。如果对报错介意的话 ,就还是使用命令行执行程序吧。

你可能感兴趣的文章
nginx实现负载均衡
查看>>
nginx常用命令及简单配置
查看>>
nginx开机启动脚本
查看>>
nginx异常:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf
查看>>
nginx总结及使用Docker创建nginx教程
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:128
查看>>
nginx报错:the “ssl“ parameter requires ngx_http_ssl_module in usrlocalnginxconfnginx.conf128
查看>>
nginx日志分割并定期删除
查看>>
Nginx日志分析系统---ElasticStack(ELK)工作笔记001
查看>>
Nginx映射本地json文件,配置解决浏览器跨域问题,提供前端get请求模拟数据
查看>>
nginx最最最详细教程来了
查看>>
Nginx服务器---正向代理
查看>>
Nginx服务器上安装SSL证书
查看>>
Nginx服务器基本配置
查看>>
Nginx服务器的安装
查看>>
Nginx标准配置文件(包括反向代理、大文件上传、Https证书配置、文件预览等)
查看>>
Nginx模块 ngx_http_limit_conn_module 限制连接数
查看>>
Nginx模块 ngx_http_limit_req_module 限制请求速率
查看>>
nginx添加模块与https支持
查看>>
nginx状态监控
查看>>