Jupyter命令只能与破折号一起使用(例如jupyter-kernelspec而不是jupyter kernelspec) [英] Jupyter commands work only with a dash (e.g. jupyter-kernelspec instead of jupyter kernelspec)
问题描述
我正在将Jupyter与Anaconda3一起使用.
I am using Jupyter with Anaconda3.
我的Anaconda3\
和Anaconda3\Scripts\
文件夹已添加到%PATH%
变量中.
My Anaconda3\
and Anaconda3\Scripts\
folders have been added to the %PATH%
variable.
尽管jupyter.exe
位于上面的Scripts
文件夹中,但Jupyter相关命令如果不加破折号,将无法正常工作.
Eventhough the jupyter.exe
is in the Scripts
folder above, Jupyter related commands don't work without a dash.
-
例如:
For example:
jupyter kernelspec --version
Error executing Jupyter command 'kernelspec': [Errno 'jupyter-kernelspec' not found] 2
带破折号的相同命令有效:
The same command with a dash works:
jupyter-kernelspec --version
5.2.2
jupyter-notebook
等也是如此
我是否必须在%PATH%
中添加其他内容?我想念什么吗?
Do I have to add anything else to my %PATH%
? Am I missing something?
我也为此在Github上打开了一个问题,但不幸的是,它没有引起任何注意:
I have opened an issue for this point on Github as well, but it didn't get any attention unfortunately: https://github.com/jupyter/jupyter/issues/381
推荐答案
好吧,我发现了问题所在.在某些Windows版本中,使用shutil
模块,由于缺少.exe
,尽管PATHEXT
环境变量同时包含.exe
和.EXE
,但which('jupyter-kernelspec')
返回None
.
Well, I figured out what's wrong. Using the shutil
module, in some Windows versions which('jupyter-kernelspec')
returns None
, because of the missing .exe
, although the PATHEXT
environment variable contains both .exe
and .EXE
.
(这似乎与此链接: shutil.which()在没有附加文件扩展名的情况下找不到程序,尽管我不相信,因为which(jupyter-kernelespec.EXE)
使用shutil
对我来说很好...)
(This seems to be linked to this: shutil.which() not finding programs without appending file extension although I am not convinced because which(jupyter-kernelespec.EXE)
using shutil
works fine for me...)
因此,必须像这样将.exe
添加到jupyter
的参数中:
So, one has to add the .exe
to the argument of jupyter
like this:
jupyter kernelspec.exe list
由于大多数Jupyter内核安装程序都使用这种命令,因此您将无法始终进行调试并检查需要在何处添加它. 该修补程序包括添加以下内容:
Because this kind of command is used by most Jupyter kernel installers, you won't always be able to go debug and check where you need to add it. The fix consists in adding this:
if cmd[-4:] != '.exe':
cmd = cmd + '.exe'
我将尝试与shutil
模块人员一起提出这一点.
I'll try to raise this point with shutil
module people.
我也更新了github问题并关闭了它. https://github.com/jupyter/jupyter/issues/381
I've updated also the github issue and closed it. https://github.com/jupyter/jupyter/issues/381
这篇关于Jupyter命令只能与破折号一起使用(例如jupyter-kernelspec而不是jupyter kernelspec)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!