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

问题描述 投票:0回答:3

运行时

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上如何解决这个问题?

python pip path centos centos7
3个回答
45
投票

此问题已在服务器故障论坛上得到解答:这里是问题的链接

您需要将以下行添加到您的

~/.bash_profile
~/.bashrc
文件中。

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

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

source ~/.bash_profile

或者只需关闭终端并打开一个新会话即可。您应该继续检查您的

PATH
以确保它包含路径。

echo $PATH

18
投票

其他答案也可以,但我找到了一种更惯用的方法,可以在 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
安装 pip3,该目录刚刚创建,并且您尚未注销 - 因此该路径语句尚未执行。

您也可以在执行完

sudo apt install
后执行.profile。


0
投票

对于那些使用MAC-OS的人

以防万一您收到如下警告:

The script normalizer is installed in '[Python/*version*/bin]' which is not on PATH

你可以运行:

export PYTHONPATH="${PYTHONPATH}:[Python/*version*/bin]"

这个问题在 the-script-is-installed-in-directory-which-is-not-pathadding-a-directory-to-path-in-centos 中讨论过 但此解决方案更具体地使用 PIP3 install [package]。

© www.soinside.com 2019 - 2024. All rights reserved.