pip/pip3 安装或升级 Python 包(第三方库)时,有时会出现下述警告( ... 为相应 script 及用户名等内容):
WARNING: The scripts ... are installed in '/home/.../.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.
大意是没有将环境变量添加到路径,如果忽略这个警告,后续可能会出现无法导入包等情形……
碰到这种情况建议先行卸载刚才进行的安装:
pip3 uninstall <package>
查看数据盘根目录下隐藏文件是 .bashrc 还是 .zshrc ,然后在终端中相应输入:
echo 'export PATH=/home/.../bin:$PATH' >>~/.bashrc
source ~/.bashrc
/home/.../bin 为警告中提示的相应路径,予以替换即可。
当