该脚本安装在非 PATH 目录中

该脚本安装在非 PATH 目录中

在使用 pip 安装 Jupiter Notebook 的过程中,系统提示脚本安装在 PATH 之外的文件夹中。这会引起任何问题吗?我该如何解决?

以下是完整日志:

Installing collected packages: six, ipython-genutils, decorator, traitlets, jupyter-core, jsonschema, nbformat, tornado, pyzmq, entrypoints, pygments, MarkupSafe, jinja2, webencodings, bleach, mistune, pandocfilters, testpath, defusedxml, nbconvert, Send2Trash, wcwidth, prompt-toolkit, parso, jedi, colorama, pickleshare, backcall, ipython, python-dateutil, jupyter-client, ipykernel, pywinpty, terminado, prometheus-client, notebook
  The scripts jupyter-migrate.exe, jupyter-troubleshoot.exe and jupyter.exe are installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script jsonschema.exe is installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script jupyter-trust.exe is installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script pygmentize.exe is installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Running setup.py install for MarkupSafe ... done
  Running setup.py install for pandocfilters ... done
  The script jupyter-nbconvert.exe is installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Running setup.py install for backcall ... done
  The scripts iptest.exe, iptest3.exe, ipython.exe and ipython3.exe are installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts jupyter-kernel.exe, jupyter-kernelspec.exe and jupyter-run.exe are installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Running setup.py install for pywinpty ... done
  Running setup.py install for prometheus-client ... done
  The scripts jupyter-bundlerextension.exe, jupyter-nbextension.exe, jupyter-notebook.exe and jupyter-serverextension.exe are installed in 'c:\users\рубена\appdata\local\programs\python\python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed MarkupSafe-1.0 Send2Trash-1.5.0 backcall-0.1.0 bleach-3.0.2 colorama-0.4.0 decorator-4.3.0 defusedxml-0.5.0 entrypoints-0.2.3 ipykernel-5.1.0 ipython-7.1.1 ipython-genutils-0.2.0 jedi-0.13.1 jinja2-2.10 jsonschema-2.6.0 jupyter-client-5.2.3 jupyter-core-4.4.0 mistune-0.8.4 nbconvert-5.4.0 nbformat-4.4.0 notebook-5.7.0 pandocfilters-1.4.2 parso-0.3.1 pickleshare-0.7.5 prometheus-client-0.4.2 prompt-toolkit-2.0.7 pygments-2.2.0 python-dateutil-2.7.5 pywinpty-0.5.4 pyzmq-17.1.2 six-1.11.0 terminado-0.8.1 testpath-0.4.2 tornado-5.1.1 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1

答案1

关于如何修复该问题的答案就在您发布的日志中。

添加位置

c:\users\рубена\appdata\local\programs\python\python37\Scripts

到 Python 路径目录。

你可以按照以下答案来回答,而不必重复说明:将目录添加到 Python 路径


这会引起什么问题吗?

如果您尝试访问该脚本而不指定确切位置,Python 将无法找到它。只有您知道这是否真的会给您带来问题。

答案2

对于 Windows,请执行以下步骤:

  1. 转到文件资源管理器。导航至 C: → 用户 →(您的用户名)→ AppData → 本地 → 程序 → Python → Python38-32(您的 Python 版本)→ 脚本

  2. 复制此路径,例如
       C:\Users\(your username)\AppData\Local\Programs\Python\Python38-32\Scripts

  3. 右键单击“计算机”、“我的电脑”或“此电脑”图标 → 选择“属性”。单击“高级系统设置”(在左侧)。(要求时输入管理员密码。)在“系统属性”窗口中,单击“环境变量”(靠近底部)。在“环境变量”窗口中,在PATH“系统变量”下搜索。选择它并单击“编辑…”。在变量值中添加分号(“;”)并粘贴您在步骤 1 中复制的路径。

  4. 关闭命令提示符窗口。打开一个新的命令提示符窗口。

您现在可以运行您想要运行的命令。

答案3

对我来说,Stese 发布的解决方案不起作用并且根本没有帮助,因此我发布它来更新帖子并帮助社区。

对于使用MAC-OS的用户


解决方案 1:

尽管我已经正确配置了$PYTHONPATH,但终端仍然无法找到安装的包。

因此,我打开了~/.bashrc(或者~/.zshrc如果您使用的是新的zsh,适用于 mac-os Catalina 10.15.x 或更新版本)并粘贴以下内容:

export PATH="${PATH}:/Users/caio.hc.oliveira/Library/Python/3.7/bin"
export PYTHONPATH="${PYTHONPATH}:/Users/caio.hc.oliveira/Library/Python/3.7/bin"

保存文件并重新启动终端。

重要的:这是配置为我的 Python 路径的示例。找到你的并替换。


解决方案 2:

如果仍然找不到该包,还有另一种可能性,即发布alias指向可执行文件的指向。

因此,在同一个文件中~/.bashrc(或者如果您使用zsh~/.zshrc),您只需在末尾附加:

alias jupyter='/Users/caio.hc.oliveira/Library/Python/3.7/bin/jupyter'

保存并重新启动终端。

重要的:这是配置为我的 Python 路径的示例。找到你的并替换。

您可以使用它来指向任何可执行文件;)

相关内容