我通常只使用命令:
pip install --user <package>
但我见过here这:
pip install <package> --install-option="--prefix=~"
也可用于绕过 sudo 权限的需要。关于这个命令,该网站说:
There is also a –user option with pip install, which installs into ~/.local. This is fine for the python module, but it puts the corr2 executable into ~/.local/bin, which is probably not in your path. The above command will instead install corr2 into ~/bin.
很明显,它的行为方式与第一个命令不同。
一种方式是否优于另一种方式?如果是,为什么?
请您参考如下方法:
官方Python包安装指南在这里:
https://packaging.python.org/en/latest/installing.html
建议创建Python virtual environments per project使用 virtualenv 命令(或 python3.4 -m venv)。
这是因为如果您正在处理多个 Python 项目,它们具有不同的依赖关系,并且拥有每个项目的安装环境是在 Python 中处理此问题的明智方法。
