我正在尝试使用GCP 的 AI Notebooks。但是,当您%pip install
使用软件包时,它会安装在系统路径之外,您无法从 shell 调用它。试图更改默认路径,但我做错了什么。将不胜感激的建议。
这是一个例子:
[1] %pip install kaggle --user
... Installing collected packages: kaggle
WARNING: The script kaggle is installed in '/home/jupyter/.local/bin' 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 kaggle-1.5.6
Note: you may need to restart the kernel to use updated packages.
#restarted the kernel
[2] import kaggle
#works
[3] !pip show kaggle
Name: kaggle
Version: 1.5.6
...
Location: /home/jupyter/.local/lib/python3.5/site-packages
...
[4] !kaggle -v #doesn't work
/bin/sh: 1: kaggle: not found
[5] !echo $PATH
/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
[6] !export PATH=$PATH:/home/jupyter/.local/lib/python3.5/site-packages
#no output
[7] !echo $PATH
/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
# path is unchanged
当我在 shell 中尝试同一!export
行时,路径会发生变化,并且 shell 会找到我的可执行文件。当我在笔记本中尝试时,它没有。