我正在尝试使用 pip 在本地安装软件包。它曾经与 --user
一起使用,但现在当我尝试它时,它会在 /usr/local/lib/
中找到包的版本,然后不安装它本地。通常它会在 ~/.local
中安装东西,但现在它只是检查包的系统范围目录,如果它在那里,它不会安装它(这不是我想要的)并且如果它不在那里,它试图将它安装在我没有写入权限的 /usr/local/lib
中。例如:
$ pip install --user rpy2
Requirement already satisfied (use --upgrade to upgrade): rpy2 in /usr/local/lib/python2.7/dist-packages/
如何使 pip install --user
始终转到 ~/.local
而不是系统范围的目录?
最佳答案
Citing Marcus Smith(pip 的维护者):
If you think the global site is out of date, and want the latest in the user site, then use:
pip install --upgrade --user SomePackage
If the global site is up to date, and you really just want the same thing duplicated in
--user
, then use:
pip install --ignore-installed --user SomePackage
(which works correctly now after the merge of #1352, which is to be released in v1.5)
如何让 pip install --user
始终转到 ~/.local
而不是系统范围的目录?
同时使用 --upgrade
和 --ignore-installed
参数。
关于python - pip 不会使用 --user 在本地安装 Python 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15418949/