10

I am using Jupyter with Anaconda3.

My Anaconda3\ and Anaconda3\Scripts\ folders have been added to the %PATH% variable.

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
    

And the same goes for jupyter-notebook, etc.

Do I have to add anything else to my %PATH%? Am I missing something?

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

byouness
  • 1,746
  • 2
  • 24
  • 41

2 Answers2

5

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.

(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...)

So, one has to add the .exe to the argument of jupyter like this:

jupyter kernelspec.exe list

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'

right before this line: https://github.com/jupyter/jupyter_core/blob/f1e18b8a52cd526c0cd1402b6041778dd60f20dc/jupyter_core/command.py#L102

I'll try to raise this point with shutil module people.

I've updated also the github issue and closed it. https://github.com/jupyter/jupyter/issues/381

byouness
  • 1,746
  • 2
  • 24
  • 41
  • Which format do you have for your hard driver? Is it NTFS case sensitive? https://stackoverflow.com/questions/33998669/windows-ntfs-and-case-sensitivity – Tarun Lalwani Jul 14 '19 at 15:23
  • Yep, it is NTFS. But although I have both `.exe` and `.EXE` in my `PATHEXT` env variable, it doesn't work unless I add the `.exe` manually as explained in my answer above. – byouness Jul 15 '19 at 08:47
  • Looking at the source, all the extension are actually used? https://github.com/python/cpython/blob/18c5f9d44dde37c0fae5585a604c6027825252d2/Lib/shutil.py#L1363 – Tarun Lalwani Jul 15 '19 at 11:17
  • I know, no idea why it doesn't actually work: `which('jupyter-kernelspec')` returns `None` while both `which('jupyter-kernelspec.EXE')` and `which('jupyter-kernelspec.exe')` return the path. And both extensions `.exe` and `.EXE` are in my PATHEXT environment variable. Anyway, I guess I'll close this point since I managed to work around my issue. Thanks a lot for your help! – byouness Jul 15 '19 at 13:45
0

Does your PATHEXT environment variable have a trailing semicolon? If so, it may be the same issue described in the similar issue you mentioned in your answer: shutil.which() not finding programs without appending file extension

Remove any trailing semicolon from PATHEXT and try again.

Ryan Shaffer
  • 405
  • 3
  • 12
  • 1
    Here is my `PATHEXT`: .`COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC` it doesn't contain a trailing semicolon. – byouness Apr 16 '20 at 20:25