在非 conda / pipenv 环境中安装 jupyter 调试器
Installing jupyter debugger in non conda / pipenv environment
我已经使用 pipenv install jupyter lab
安装了 jupyter lab。
但是在创建新笔记本时,它没有显示 xpython 内核选项。
因此使用 pipenv install xeus-python
显式安装了 xpython 内核。
我还按照 xeus-python docs 的建议执行了 pip install notebook
。
现在我可以用 xpython kernel:
创建笔记本了
但是我无法启用调试。那是我的 UI 没有启用调试按钮:
尝试从实验室安装调试器扩展时出现此错误:
所以我在 windows 10 上安装了节点。但是 node
和 npm
无法从 pipenv
环境访问:
(pipenv_env) F:\user\workspaces\pipenv_env>node
'node' is not recognized as an internal or external command,
operable program or batch file.
(pipenv_env) F:\user\workspaces\pipenv_env>npm
'npm' is not recognized as an internal or external command,
operable program or batch file.
所以,我设置路径:
(pipenv_env) F:\user\workspaces\pipenv_env>SET PATH=C:\Program Files\Nodejs;%PATH%
然后我就可以按照说明安装扩展 here:
(pipenv_env) F:\user\workspaces\pipenv_env>jupyter labextension install @jupyterlab/debugger
Building jupyterlab assets (production, minimized)
-
(pipenv_env) F:\user\workspaces\pipenv_env>jupyter labextension list
JupyterLab v3.0.12
Other labextensions (built into JupyterLab)
app dir: C:\Users\user\.virtualenvs\pipenv_env\share\jupyter\lab
@jupyterlab/debugger v3.0.8 enabled ok
但我仍然无法在 jupyter lab 中获得调试器按钮,即使在我已设置节点路径的同一终端重新启动 jupyter lab 之后也是如此。
jupyter 中的调试是否仅适用于 conda?
切换到 jupyter lab 扩展管理器选项卡,它说需要构建:
(上图来自 google 搜索,我的扩展管理器列出了调试器)
我让它完成重建。
然后,我很快尝试使用 xpython pernet 创建新单元并 运行 它,但是 jupyter lab 一直说 Connecting to kernel...
一段时间然后切换到 No kernel
状态。所以,我意识到现在内核存在一些问题。我检查了控制台并发现了以下日志:
[I 2021-03-20 17:44:39.684 ServerApp] Kernel started: 81e125aa-9fcc-4f15-9a23-efa802f0f7b4
[I 2021-03-20 17:44:51.754 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports
f:\programfiles\python37\python.exe: No module named xpython_launcher
[W 2021-03-20 17:44:54.773 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2021-03-20 17:44:54.773 ServerApp] Kernel 81e125aa-9fcc-4f15-9a23-efa802f0f7b4 died, removing from map.
[W 2021-03-20 17:45:10.187 ServerApp] Timeout waiting for kernel_info reply from 410fab88-88ee-4325-917f-f903903c51ac
[E 2021-03-20 17:45:10.188 ServerApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 410fab88-88ee-4325-917f-f903903c51ac)
所以我很快就 google 遇到了 this 问题。在文件 C:\Users\user\.virtualenv\pipenv_env\share\jupyter\kernels\xpython\kernel.json
中将 python.exe
更改为 python
有效:
{
"display_name": "Python 3.7 (XPython)",
"argv": [
"python",
"-m",
"xpython_launcher",
"-f",
"{connection_file}"
],
"language": "python",
"metadata": { "debugger": true }
}
现在,我获得了启用调试按钮,还能够添加断点和调试。
我已经使用 pipenv install jupyter lab
安装了 jupyter lab。
但是在创建新笔记本时,它没有显示 xpython 内核选项。
因此使用 pipenv install xeus-python
显式安装了 xpython 内核。
我还按照 xeus-python docs 的建议执行了 pip install notebook
。
现在我可以用 xpython kernel:
但是我无法启用调试。那是我的 UI 没有启用调试按钮:
尝试从实验室安装调试器扩展时出现此错误:
所以我在 windows 10 上安装了节点。但是 node
和 npm
无法从 pipenv
环境访问:
(pipenv_env) F:\user\workspaces\pipenv_env>node
'node' is not recognized as an internal or external command,
operable program or batch file.
(pipenv_env) F:\user\workspaces\pipenv_env>npm
'npm' is not recognized as an internal or external command,
operable program or batch file.
所以,我设置路径:
(pipenv_env) F:\user\workspaces\pipenv_env>SET PATH=C:\Program Files\Nodejs;%PATH%
然后我就可以按照说明安装扩展 here:
(pipenv_env) F:\user\workspaces\pipenv_env>jupyter labextension install @jupyterlab/debugger
Building jupyterlab assets (production, minimized)
-
(pipenv_env) F:\user\workspaces\pipenv_env>jupyter labextension list
JupyterLab v3.0.12
Other labextensions (built into JupyterLab)
app dir: C:\Users\user\.virtualenvs\pipenv_env\share\jupyter\lab
@jupyterlab/debugger v3.0.8 enabled ok
但我仍然无法在 jupyter lab 中获得调试器按钮,即使在我已设置节点路径的同一终端重新启动 jupyter lab 之后也是如此。
jupyter 中的调试是否仅适用于 conda?
切换到 jupyter lab 扩展管理器选项卡,它说需要构建:
(上图来自 google 搜索,我的扩展管理器列出了调试器)
我让它完成重建。
然后,我很快尝试使用 xpython pernet 创建新单元并 运行 它,但是 jupyter lab 一直说 Connecting to kernel...
一段时间然后切换到 No kernel
状态。所以,我意识到现在内核存在一些问题。我检查了控制台并发现了以下日志:
[I 2021-03-20 17:44:39.684 ServerApp] Kernel started: 81e125aa-9fcc-4f15-9a23-efa802f0f7b4
[I 2021-03-20 17:44:51.754 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5), new random ports
f:\programfiles\python37\python.exe: No module named xpython_launcher
[W 2021-03-20 17:44:54.773 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2021-03-20 17:44:54.773 ServerApp] Kernel 81e125aa-9fcc-4f15-9a23-efa802f0f7b4 died, removing from map.
[W 2021-03-20 17:45:10.187 ServerApp] Timeout waiting for kernel_info reply from 410fab88-88ee-4325-917f-f903903c51ac
[E 2021-03-20 17:45:10.188 ServerApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 410fab88-88ee-4325-917f-f903903c51ac)
所以我很快就 google 遇到了 this 问题。在文件 C:\Users\user\.virtualenv\pipenv_env\share\jupyter\kernels\xpython\kernel.json
中将 python.exe
更改为 python
有效:
{
"display_name": "Python 3.7 (XPython)",
"argv": [
"python",
"-m",
"xpython_launcher",
"-f",
"{connection_file}"
],
"language": "python",
"metadata": { "debugger": true }
}
现在,我获得了启用调试按钮,还能够添加断点和调试。