[英]Why should I install Python packages into `~/.local`?
~/.local
?~/.local
安装五个基本包? Since I'm installing these base packages into the site-packages directories of Python distributions that I've installed, I'm isolated from the OS X's Python distributions. Again, I'm only interested in where to install those five base packages.同样,我只对安装这五个基本软件包的位置感兴趣。
I'm asking because of Glyph 's comment to my answer to SO question 4314376 , which stated:我问是因为Glyph对我对SO 问题 4314376 的回答的评论,其中指出:
NO.
否。 NEVER EVER do
sudo python setup.py install
whatever.永远不要做
sudo python setup.py install
什么的。 Write a ~/.pydistutils.cfg that puts your pip installation into ~/.local or something.编写一个 ~/.pydistutils.cfg 将您的 pip 安装放入 ~/.local 或其他东西。 Especially files named
ez_setup.py
tend to suck down newer versions of things like setuptools and easy_install, which can potentially break other things on your operating system.特别是名为
ez_setup.py
文件往往会吸收更新版本的东西,比如 setuptools 和 easy_install,这可能会破坏操作系统上的其他东西。
Previously, I asked What's the proper way to install pip, virtualenv, and distribute for Python?之前,我问过为 Python 安装 pip、virtualenv 和分发的正确方法是什么? .
. However, no one answered the "why" of using
~/.local
.但是,没有人回答使用
~/.local
的“原因”。
There's no particularly good reason for or against installing in .local
for Mac OS X installations using framework builds.对于使用框架构建的 Mac OS X 安装,没有特别好的理由支持或反对在
.local
中安装。 There is still some controversy among Python core developers on this point with Glyph arguing that the .local
location, introduced in Python 2.6 for other Unixy systems, should be used for Mac OS X and simplifies third-party installation processes, while others argue that the previous traditional locations for Mac OS X framework builds is more natural. Python 核心开发人员在这一点上仍然存在一些争议,Glyph 认为在 Python 2.6 中为其他Unixy系统引入的
.local
位置应该用于 Mac OS X 并简化第三方安装过程,而其他人则认为以前的传统位置为 Mac OS X 框架构建更自然。 In the end, it is up to you.最后,这取决于你。 Particularly if you are using virtual environments, if it works, don't worry about it.
特别是如果您正在使用虚拟环境,如果它有效,请不要担心。
As of 2020, I do not think it is a good idea to install Python packages into .local
, but to use virtualenv
to create a separate environment for each package.截至 2020 年,我认为将 Python 包安装到
.local
不是一个好主意,而是使用virtualenv
为每个包创建单独的环境。
My reason我的理由
While installations into .local
do not interfere with the system wide Python, you still can have conflicts between several packages installed into .local
.虽然安装到
.local
不会干扰系统范围的 Python,但安装到.local
几个包之间仍然可能存在冲突。
PS: If you do you like virtualenv
you could also use pipx
. PS:如果你喜欢
virtualenv
你也可以使用pipx
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.