包可以在Anaconda环境中共享吗? [英] Can packages be shared across Anaconda environments?

查看:1967
本文介绍了包可以在Anaconda环境中共享吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的~/anaconda目录占用了过多的磁盘空间(10GB),尽管我只有五个环境并且运行了conda clean.我发现,当我尝试创建新的conda环境时,Anaconda显示了非常长的要下载的软件包列表,其中似乎包含完整的科学Python堆栈(Python解释器,numpy,scipy等).似乎Anaconda正在为每种环境独立安装所有组件.这是真的吗?

My ~/anaconda directory is taking up too much disk space (10GB), although I have only five environments and have run conda clean. I discovered that when I try to create a new conda environment, Anaconda displays a very long list of packages to be downloaded, which seems to include a full scientific Python stack (Python interpreter, numpy, scipy, etc.). It seems that Anaconda is installing everything independently for each environment. Is this true?

以下列表包含一些纯粹的推测性方法,可以潜在地解决空间问题:

The following list contains some purely speculative ways which could potentially solve the space problem:

  • 我可以创建一个子环境"来继承"父环境"的程序包吗?
  • 可以使Anaconda共享(例如通过文件系统上的符号链接)在不同环境中使用的相同软件包吗?
  • 在程序包管理方面,默认环境是否有任何特殊状态?我使用Anaconda 2,但大多数环境使用Python3.我可以切换到Anaconda 3来节省空间吗? (这将默认环境视为所有其他环境的父环境".)
  • 我通常使用pip来安装软件包,因为conda install通常会失败. conda install做一些聪明的工作来重用已经安装在其他地方的软件包吗?
  • Can I create a "sub-environment" which "inherits" the packages of a "parent environment"?
  • Can Anaconda be made to share (e.g. via symbolic links on the file system) the same packages used in different environments?
  • Does the default environment have any special status in terms of package managing? I use Anaconda 2, but most of my environments use Python 3. Can I save space by switching to Anaconda 3? (This is regarding the default environment as the "parent environment" of all other environments.)
  • I normally use pip to install packages, as conda install often fails. Does conda install do some smart job to reuse packages already installed somewhere else?

(调试信息)我在~/anaconda/envs下的四个环境目录的大小在1.2GB和2.6GB之间.这正常吗?

(Debugging information) The sizes of my four environment directories under ~/anaconda/envs are between 1.2GB and 2.6GB. Is this normal?

推荐答案

我相信您的主要问题的答案在于

I believe the answer to your main question lies in the difference between Anaconda vs Miniconda. Anaconda includes a long list of packages that get installed automatically into each environment that you create. Miniconda creates barebone conda virtual environments (which don't contain many packages at all). Switching to Miniconda should substantially reduce the size/number of packages in your environments. Anaconda is about 2GB, while Miniconda is closer to 100MB.

conda install相比,Conda还使用硬链接来安装软件包.可以在中找到对硬链接的良好描述.这里.它们基本上将跨多个环境的依赖关系链接到了您上面所述的位置.通过pip安装的软件包没有进行硬链接,因此它们无法利用conda软件包所提供的空间节省.

Conda also uses hardlinks for packages installed vs conda install. A good description of hardlinks can be found here. They basically link dependencies across multiple environments like you've described above. Packages installed via pip are not hardlinked, so they cannot take advantage of the space savings that conda packages offer.

这篇关于包可以在Anaconda环境中共享吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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