正如pip 文档中所解释的,用户可以使用pip install --user <pkg>.
如何以编程方式确定像这样安装的脚本的用户安装位置?我说的是应该添加到 PATH 中的目录,以便可以从命令行调用已安装的包。
例如,在 Windows 中安装时,我收到以下警告,因为我的 PATH 中pip install -U pylint --user没有:'C:\Users\myusername\AppData\Roaming\Python\Python37\Scripts'
...
Installing collected packages: wrapt, six, typed-ast, lazy-object-proxy, astroid, mccabe, isort, colorama, toml, pylint
Running setup.py install for wrapt ... done
WARNING: The script isort.exe is installed in 'C:\Users\myusername\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts epylint.exe, pylint.exe, pyreverse.exe …Run Code Online (Sandbox Code Playgroud)