- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
看来我的一个内核不知何故被删除了。也许这就是我收到此错误的原因。我怎么可能修好它?我可以重新安装一些东西吗(也许是基础环境中的内核)?
如果没有更好的选择,作为最后的手段,我会尝试完全重新安装 anaconda:Default kernel in jupyter notebook (Python3) not working .
我试过使用以下方法:
requirements already satisfied
jupyter kernelspec list
输出:
Available kernels:
python3 C:\Users\raysu\AppData\Roaming\jupyter\kernels\python3
vpython C:\ProgramData\jupyter\kernels\vpython
但我必须有另一个与我的基本环境相关联的内核(我想它不知何故被删除了)。
C:\Users\raysu\Documents>conda env list
# conda environments:
#
base * C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64
astra_env C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\astra_env
bokeh_env C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\bokeh_env
sound_env C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\sound_env
tf_env C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\envs\tf_env
C:\Users\raysu\Anaconda3
C:\Users\raysu\Anaconda3\envs\pyforge
opencv_env C:\Users\raysu\AppData\Local\conda\conda\envs\opencv_env
test_env C:\Users\raysu\AppData\Local\conda\conda\envs\test_env
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\raysu\AppData\Roaming\Python\Python36\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\raysu\AppData\Roaming\Python\Python36\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\raysu\AppData\Roaming\Python\Python36\site-packages\jupyter_client\connect.py", line 476, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\raysu\AppData\Roaming\Python\Python36\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\contextlib.py", line 81, in __enter__
return next(self.gen)
File "C:\Users\raysu\AppData\Roaming\Python\Python36\site-packages\jupyter_core\paths.py", line 404, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\raysu\AppData\Roaming\Python\Python36\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.
最佳答案
Solved the problem by editing the relevant
kernelspec
:kernel.json
file after fresh installation of Anaconda.
如前所述,我发现我有两个 kernelspecs
。 (命令:jupyter kernelspec list
)
C:\Users\raysu\AppData\Roaming\jupyter\kernels\python3
C:\ProgramData\jupyter\kernels\vpython
kernelspec
是一个 .json
文件,它维护 jupyter-notebook/lab 启动某个内核的内核规范。幸运的是,内核 vpython
正在运行,这帮助我缩小了位于 kernelpsec: python3
。我必须更正 python 可执行文件 (python.exe
) 的路径,这才解决了问题。
我想提一下,在这种情况下,以下两种资源派上了用场。在看到 kernelspec
文档的typical-structure 之后,我更加清楚了问题可能出在哪里。
注意:但是,由于我无法测试这个理论,所以我会请遇到类似问题的其他人先复制旧的 kernel.json
文件然后更新 python.exe
文件的路径。如果这解决了内核错误,则可能不需要完全重新安装 Anaconda。
Long story short:
如果您的 jupyter notebook/lab 环境显示内核错误,问题的根源很可能在 kernelspec 文件中:kernel.json
和 python.exe
的路径不正确。如果即使在重新安装 anaconda/jupyter-notebook/lab 后相同的 kernel error
仍然存在,这可能是一种更可能的情况。
例如,在我的例子中,python3-kernelspec
位于:
"C:\Users\raysu\AppData\Roaming\jupyter\kernels\python3"
python.exe
位于:
"C:\Users\raysu\Anaconda3\python.exe"
但是,python-executable 的路径是错误的:它仍然显示旧安装的路径。在重新安装 anaconda 之后,这条路径发生了变化。因此,我必须通过编辑 kernel.json
文件来更新 python3 的 kernelspec。
# kernel.json file
{
"argv": [
"C:\\Users\\raysu\\Anaconda3\\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
如果这不能解决您的问题,请查阅以下两个文档。我因此浪费了4天。希望这个答案将来能对某人有所帮助。
关于python - Jupyter 实验室和笔记本问题 : Kernel Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58459493/
我正在处理一组标记为 160 个组的 173k 点。我想通过合并最接近的(到 9 或 10 个组)来减少组/集群的数量。我搜索过 sklearn 或类似的库,但没有成功。 我猜它只是通过 knn 聚类
我有一个扁平数字列表,这些数字逻辑上以 3 为一组,其中每个三元组是 (number, __ignored, flag[0 or 1]),例如: [7,56,1, 8,0,0, 2,0,0, 6,1,
我正在使用 pipenv 来管理我的包。我想编写一个 python 脚本来调用另一个使用不同虚拟环境(VE)的 python 脚本。 如何运行使用 VE1 的 python 脚本 1 并调用另一个 p
假设我有一个文件 script.py 位于 path = "foo/bar/script.py"。我正在寻找一种在 Python 中通过函数 execute_script() 从我的主要 Python
这听起来像是谜语或笑话,但实际上我还没有找到这个问题的答案。 问题到底是什么? 我想运行 2 个脚本。在第一个脚本中,我调用另一个脚本,但我希望它们继续并行,而不是在两个单独的线程中。主要是我不希望第
我有一个带有 python 2.5.5 的软件。我想发送一个命令,该命令将在 python 2.7.5 中启动一个脚本,然后继续执行该脚本。 我试过用 #!python2.7.5 和http://re
我在 python 命令行(使用 python 2.7)中,并尝试运行 Python 脚本。我的操作系统是 Windows 7。我已将我的目录设置为包含我所有脚本的文件夹,使用: os.chdir("
剧透:部分解决(见最后)。 以下是使用 Python 嵌入的代码示例: #include int main(int argc, char** argv) { Py_SetPythonHome
假设我有以下列表,对应于及时的股票价格: prices = [1, 3, 7, 10, 9, 8, 5, 3, 6, 8, 12, 9, 6, 10, 13, 8, 4, 11] 我想确定以下总体上最
所以我试图在选择某个单选按钮时更改此框架的背景。 我的框架位于一个类中,并且单选按钮的功能位于该类之外。 (这样我就可以在所有其他框架上调用它们。) 问题是每当我选择单选按钮时都会出现以下错误: co
我正在尝试将字符串与 python 中的正则表达式进行比较,如下所示, #!/usr/bin/env python3 import re str1 = "Expecting property name
考虑以下原型(prototype) Boost.Python 模块,该模块从单独的 C++ 头文件中引入类“D”。 /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c)
如何编写一个程序来“识别函数调用的行号?” python 检查模块提供了定位行号的选项,但是, def di(): return inspect.currentframe().f_back.f_l
我已经使用 macports 安装了 Python 2.7,并且由于我的 $PATH 变量,这就是我输入 $ python 时得到的变量。然而,virtualenv 默认使用 Python 2.6,除
我只想问如何加快 python 上的 re.search 速度。 我有一个很长的字符串行,长度为 176861(即带有一些符号的字母数字字符),我使用此函数测试了该行以进行研究: def getExe
list1= [u'%app%%General%%Council%', u'%people%', u'%people%%Regional%%Council%%Mandate%', u'%ppp%%Ge
这个问题在这里已经有了答案: Is it Pythonic to use list comprehensions for just side effects? (7 个答案) 关闭 4 个月前。 告
我想用 Python 将两个列表组合成一个列表,方法如下: a = [1,1,1,2,2,2,3,3,3,3] b= ["Sun", "is", "bright", "June","and" ,"Ju
我正在运行带有最新 Boost 发行版 (1.55.0) 的 Mac OS X 10.8.4 (Darwin 12.4.0)。我正在按照说明 here构建包含在我的发行版中的教程 Boost-Pyth
学习 Python,我正在尝试制作一个没有任何第 3 方库的网络抓取工具,这样过程对我来说并没有简化,而且我知道我在做什么。我浏览了一些在线资源,但所有这些都让我对某些事情感到困惑。 html 看起来
我是一名优秀的程序员,十分优秀!