使用 pip 且没有 sudo 权限安装 Python 包的推荐方法
Recommended way to install a Python package with pip and no sudo privileges
我通常只使用命令:
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
建议使用 virtualenv
命令(或 python3.4 -m venv
)创建 Python virtual environments per project。
这是因为如果您正在处理多个 Python 项目,它们具有不同的依赖关系,并且在 Python.
中拥有每个项目的安装环境是处理此问题的明智方法
我通常只使用命令:
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
建议使用 virtualenv
命令(或 python3.4 -m venv
)创建 Python virtual environments per project。
这是因为如果您正在处理多个 Python 项目,它们具有不同的依赖关系,并且在 Python.
中拥有每个项目的安装环境是处理此问题的明智方法