RuntimeError: This event loop is already running”问题解决

Posted 朱小勇

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RuntimeError: This event loop is already running”问题解决相关的知识,希望对你有一定的参考价值。

1.问题描述

在spyder中使用asyncio就会报着个错

2.解决

添加:

import nest_asyncio
nest_asyncio.apply()

 

jupyter 报错 raise RuntimeError(‘This event loop is already running‘)

使用anaconda时jupyter报错: raise RuntimeError(‘This event loop is already running’); 这是由于ipykernel冲突导致的

解决办法:
建议在base环境中安装 ipykernel

conda install ipykernel

把报错环境中的ipykernel、jupyter都卸载了

conda activate py37
conda uninstall ipykernel
conda uninstall jupyter
然后安装最新版的
pip install jupyter
pip install ipykernel==5.5.6

在base里启动jupyter

conda activate base
jupyter notebook

在选择kernel的时候选择py37的就行了

以上是关于RuntimeError: This event loop is already running”问题解决的主要内容,如果未能解决你的问题,请参考以下文章

jupyter 报错 raise RuntimeError(‘This event loop is already running‘)

Python 成功解决报错 asyncio RuntimeError: This event loop is already running

从 django urls 运行的 websockets 错误:RuntimeError: There is no current event loop in thread 'Dummy-1'

[未解决问题记录]python asyncio+aiohttp出现Exception ignored:RuntimeError('Event loop is closed')(代码片段

RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa

asyncio:RuntimeError此事件循环已在运行