Jupyter命令只能与破折号一起使用(例如,jupyterkernelspec而不是Jupyter kernelspec)

2024-04-25 13:28:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用Jupyter和水蟒。在

我的Anaconda3\Anaconda3\Scripts\文件夹已添加到%PATH%变量中。在

即使jupyter.exe在上面的Scripts文件夹中,与Jupyter相关的命令在没有破折号的情况下无法工作。在

  • 例如:

    jupyter kernelspec --version
    Error executing Jupyter command 'kernelspec': [Errno 'jupyter-kernelspec' not found] 2
    
  • 使用破折号的同一个命令起作用:

    jupyter-kernelspec --version
    5.2.2
    

jupyter-notebook等也是如此

我还需要在我的%PATH%中添加其他内容吗?我错过什么了吗?在

我在Github上也为这一点打开了一个问题,但不幸的是没有引起任何注意:https://github.com/jupyter/jupyter/issues/381


Tags: 命令文件夹versionscripts情况jupytererrorexe
1条回答
网友
1楼 · 发布于 2024-04-25 13:28:27

好吧,我知道怎么了。使用shutil模块,在某些Windows版本中which('jupyter-kernelspec')返回{},因为缺少{},尽管{}环境变量同时包含{}和{}。在

(这似乎与此有关:shutil.which() not finding programs without appending file extension虽然我不相信,因为which(jupyter-kernelespec.EXE)使用shutil对我来说很好…)

因此,我们必须将.exe添加到jupyter的参数中,如下所示:

jupyter kernelspec.exe list

因为大多数Jupyter内核安装程序都使用这种命令,所以您并不总是能够进行调试并检查需要添加到哪里。 解决方法是添加以下内容:

^{pr2}$

就在这行之前: https://github.com/jupyter/jupyter_core/blob/f1e18b8a52cd526c0cd1402b6041778dd60f20dc/jupyter_core/command.py#L102

我将尝试向shutil模块人员提出这一点。在

我也更新了github问题并关闭了它。 https://github.com/jupyter/jupyter/issues/381

相关问题 更多 >