为什么要安装软件包而不是仅将其链接到特定环境? [英] Why are packages installed rather than just linked to a specific environment?

查看:131
本文介绍了为什么要安装软件包而不是仅将其链接到特定环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,通常使用各种软件包管理器(适用于python)安装软件包时,它们会安装在conda上的/home/user/anaconda3/envs/env_name/中,并使用conda上的pip安装在/home/user/anaconda3/envs/env_name/lib/python3.6/lib-packages/中.

I've noticed that normally when packages are installed using various package managers (for python), they are installed in /home/user/anaconda3/envs/env_name/ on conda and in /home/user/anaconda3/envs/env_name/lib/python3.6/lib-packages/ using pip on conda.

但是conda也会缓存所有最近下载的软件包.

But conda caches all the recently downloaded packages too.

所以,我的问题是: 为什么conda不能将所有软件包都安装在中央位置,然后在特定环境中安装时创建指向目录的链接,而不是将其安装在目录中?

So, my question is: Why doesn't conda install all the packages on a central location and then when installed in a specific environment create a link to the directory rather than installing it there?

我注意到环境越来越大,这种方法可能可以节省一些空间.

I've noticed that environments grow quite big and that this method would probably be able to save a bit of space.

推荐答案

Conda已经做到了.但是,由于它利用了 hardlinks ,因此容易高估实际使用的空间,尤其是如果一次仅查看单个env的大小的话.

Conda already does this. However, because it leverages hardlinks, it is easy to overestimate the space really being used, especially if one only looks at the size of a single env at a time.

为说明这种情况,让我们使用du检查实际磁盘使用情况.首先,如果我分别计算每个环境目录,我会得到每个环境使用情况未修正的信息

To illustrate the case, let's use du to inspect the real disk usage. First, if I count each environment directory individually, I get the uncorrected per env usage

$ for d in envs/*; do du -sh $d; done
2.4G    envs/pymc36
1.7G    envs/pymc3_27
1.4G    envs/r-keras
1.7G    envs/stan
1.2G    envs/velocyto

这是从GUI看起来的样子.

which is what it might look like from a GUI.

相反,如果我让du一起计算(即,对硬链接进行更正),我们将得到

Instead, if I let du count them together (i.e., correcting for the hardlinks), we get

$ du -sh envs/*
2.4G    envs/pymc36
326M    envs/pymc3_27
820M    envs/r-keras
927M    envs/stan
548M    envs/velocyto

可以看到这里已经节省了大量空间.

One can see that a significant amount of space is already being saved here.

大多数硬链接都返回到pkgs目录,因此,如果我们也将其包括在内:

Most of the hardlinks go back to the pkgs directory, so if we include that as well:

$ du -sh pkgs envs/*
8.2G    pkgs
400M    envs/pymc36
116M    envs/pymc3_27
 92M    envs/r-keras
 62M    envs/stan
162M    envs/velocyto

可以看到,在共享软件包之外,env相当轻巧.如果您担心我的pkgs的大小,请注意,我从未在此系统上运行conda clean,因此我的pkgs目录中充满了tarball和被取代的软件包,以及我保存在中的一些基础结构基本(例如Jupyter,Git等).

one can see that outside of the shared packages, the envs are fairly light. If you're concerned about the size of my pkgs, note that I have never run conda clean on this system, so my pkgs directory is full of tarballs and superseded packages, plus some infrastructure I keep in base (e.g., Jupyter, Git, etc).

这篇关于为什么要安装软件包而不是仅将其链接到特定环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆