“jupyter-kernelspec” not found while installing iqsharp however it exists on PATH

房东的猫 提交于 2020-04-18 05:45:47

问题


While installing QDK for use with python as described in this guide, on executing dotnet iqsharp install I get the following exception

Traceback (most recent call last):
  File "c:\users\hp\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\hp\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python36\Scripts\jupyter.exe\__main__.py", line 7, in <module>
  File "c:\users\hp\appdata\local\programs\python\python36\lib\site-packages\jupyter_core\command.py", line 247, in main
    command = _jupyter_abspath(subcommand)
  File "c:\users\hp\appdata\local\programs\python\python36\lib\site-packages\jupyter_core\command.py", line 134, in _jupyter_abspath
    'Jupyter command `{}` not found.'.format(jupyter_subcommand)
Exception: Jupyter command `jupyter-kernelspec` not found.

However, when I run jupyter-kernelspec command on cmd it is found on PATH. Why is it happening that python is unable to locate a command if cmd can find it?


回答1:


To address your specific question, you can see whether Python can locate jupyter-kernelspec (and if so, where) by running something like:

python -c "from shutil import which; print(which('jupyter-kernelspec'))"

But as to the underlying cause of the error, it seems likely that your Jupyter installation is incomplete and/or your environment is somehow misconfigured. You may want to try creating a new Python environment (perhaps using Anaconda, if you're new to Python development) and then following the QDK installation instructions again from inside that new environment (e.g., from an Anaconda command prompt with the new environment active).

Edit: From comments below, it sounds like the problem is that you have a trailing semicolon in your PATHEXT environment variable. This confuses shutil.which(), and this in turn prevents Jupyter from finding the necessary executable. (I can reproduce this problem locally by adding a trailing semicolon to PATHEXT.)

The fix should be simply to remove the trailing semicolon from PATHEXT.



来源:https://stackoverflow.com/questions/61097406/jupyter-kernelspec-not-found-while-installing-iqsharp-however-it-exists-on-pat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!