centos 警告:脚本pip3.8安装在不在PATH中的“/usr/local/bin”中

44u64gxh  于 2022-11-07  发布在  其他
关注(0)|答案(2)|浏览(110)

当运行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

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

nkoocmlb

nkoocmlb1#

此问题已在serverfaults论坛上得到解答:这是一个link to the question
您需要将以下行添加到~/.bash_profile~/.bashrc文件中。

export PATH="/usr/local/bin:$PATH"

然后,您将需要进行性能分析,通过运行以下命令之一执行此操作:

source ~/.bash_profile

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

echo $PATH
juzqafwq

juzqafwq2#

其他的答案也可以,但是我发现了一个更惯用的方法,可以在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

将执行并在您登录时自动将.local/bin添加到您的路径中。
如果您通过sudo apt install python3-pip安装pip 3,则该目录刚刚创建,并且您还没有注销-因此path语句没有执行。
您也可以在执行sudo apt install之后执行.profile。

相关问题