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

byo*_*ess 7 python python-3.x anaconda jupyter jupyter-notebook

我在Anaconda3中使用Jupyter。

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

即使位于上面jupyter.exeScripts文件夹中,与Jupyter相关的命令也不能不加破折号。

jupyter-notebook等等也一样。

我是否还需要添加其他内容%PATH%?我想念什么吗?

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

byo*_*ess 5

好吧,我想出了什么问题。使用该shutil模块,在某些 Windows 版本中会which('jupyter-kernelspec')返回None,因为缺少.exe,尽管PATHEXT环境变量包含.exe.EXE

(这似乎与此相关:shutil.which() 没有找到没有附加文件扩展名的程序虽然我不相信,因为which(jupyter-kernelespec.EXE)使用shutil对我来说很好......)

因此,必须将.exe加到jupyter像这样的参数中:

jupyter kernelspec.exe list
Run Code Online (Sandbox Code Playgroud)

由于大多数 Jupyter 内核安装程序都使用这种命令,因此您将无法始终进行调试并检查需要添加它的位置。修复包括添加以下内容:

if cmd[-4:] != '.exe':
    cmd = cmd + '.exe'
Run Code Online (Sandbox Code Playgroud)

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

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

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