python
install_error
ai_generated
true
警告:脚本 foo 安装在 '/home/user/.local/bin',该目录不在 PATH 中。 请考虑将此目录添加到 PATH,或若希望抑制此警告,请使用 --no-warn-script-location。
WARNING: The script foo is installed in '/home/user/.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.
ID: python/pip-legacy-version-scheme
80%修复率
83%置信度
0证据数
2024-08-21首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
由于使用了 --user 或未激活的 venv,pip 将 console_scripts 安装到用户 site bin 目录,但该目录不在 shell 的 PATH 中,因此找不到命令。
English
pip installed console_scripts into the user site bin directory (because of --user or a non-activated venv), but that directory is not on the shell's PATH, so the command isn't found.
解决方案
-
90% 成功率
Add the dir to PATH: export PATH="$HOME/.local/bin:$PATH" # append to ~/.bashrc or ~/.zshrc to persist
-
88% 成功率
Use a venv so scripts install into the active env: python -m venv .venv && . .venv/bin/activate && pip install foo
无效尝试
常见但无效的做法:
-
75% 失败
Suppresses the warning but the script still lands off-PATH; running foo still gives command not found.
-
70% 失败
Reinstalls to the same location; PATH is unchanged so the command remains undiscoverable.