警告:脚本 pip3.8 安装在 '/usr/local/bin' 中,该路径不在 PATH 上

Edw*_*ard 31 python centos pip path centos7

运行时,pip3.8我的终端中出现以下警告

WARNING: The script pip3.8 is installed in '/usr/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 pip-21.1.1 setuptools-56.0.0
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
Run Code Online (Sandbox Code Playgroud)

在centos 7上如何解决这个问题?

Mat*_*our 54

这个问题已在 serverfaults 论坛上得到解答:这是问题的链接

您需要将以下行添加到您的~/.bash_profile~/.bashrc文件中。

 export PATH="/usr/local/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)

然后,您需要进行分析,通过运行以下命令来执行此操作:

source ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)

或者只需关闭终端并打开一个新会话即可。您应该继续检查PATH以确保它包含该路径。

echo $PATH
Run Code Online (Sandbox Code Playgroud)

  • bin 后面缺少冒号吗? (2认同)

J. *_*ner 19

其他答案也可以,但我找到了一种更惯用的方法,可以在 AWS 全新安装的 Ubuntu 20.04 上执行此操作。

该路径声明已经存在,但在 .profile 中

您需要注销,然后重新登录。获取环境无法做到这一点。

原因:

在.profile中,代码:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
Run Code Online (Sandbox Code Playgroud)

当您登录时,将执行并自动将 .local/bin 添加到您的路径中。

如果您通过sudo apt install python3-pip刚刚创建的目录安装 pip3,并且您尚未注销 - 因此该路径语句尚未执行。

您还可以在执行 .profile 之后执行 .profile sudo apt install