“ jupyter-kernelspec”安装iqsharp时找不到,但是它存在于PATH中 [英] "jupyter-kernelspec" not found while installing iqsharp however it exists on PATH

查看:233
本文介绍了“ jupyter-kernelspec”安装iqsharp时找不到,但是它存在于PATH中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照本指南中所述安装QDK以与python配合使用时,,在执行 dotnet iqsharp安装时,出现以下异常

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.

但是,当我运行 jupyter-kernelspec 在cmd上的命令可以在PATH中找到。如果cmd能够找到命令,为什么python无法找到命令?

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?

推荐答案

要解决您的特定问题,您可以通过运行以下命令查看Python是否可以找到jupyter-kernelspec(如果可以,在哪里):

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'))"

但是对于底层导致该错误的原因,您的Jupyter安装似乎不完整和/或您的环境配置不正确。您可能想尝试创建新的Python环境(如果您不熟悉,也许使用 Anaconda )。 Python开发),然后在该新环境中(例如,在新环境处于活动状态的Anaconda命令提示符下)再次遵循QDK安装说明。

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

编辑:从下面的评论看来,问题在于您的 PATHEXT 环境变量中包含尾随分号。这会混淆 shutil.which(),进而阻止Jupyter查找必需的可执行文件。 (我可以通过在 PATHEXT 中添加尾部分号在本地重现此问题。)

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

解决方法应该很简单从 PATHEXT 中删除​​结尾的分号。

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

这篇关于“ jupyter-kernelspec”安装iqsharp时找不到,但是它存在于PATH中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆