本文介绍了如何跨平台共享conda环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

位于解释了如何与他人共享环境。

The conda docs at http://conda.pydata.org/docs/using/envs.html explain how to share environments with other people.

但是,文档告诉我们这不是跨平台的:

However, the docs tell us this is not cross platform:

NOTE: These explicit spec files are not usually cross platform, and
therefore have a comment at the top such as # platform: osx-64 showing the
platform where they were created. This platform is the one where this spec
file is known to work. On other platforms, the packages specified might not
be available or dependencies might be missing for some of the key packages
already in the spec.

NOTE: Conda does not check architecture or dependencies when installing
from an explicit specification file. To ensure the packages work correctly,
be sure that the file was created from a working environment and that it is
used on the same architecture, operating system and platform, such as linux-
64 or osx-64.

在一个平台(例如CentOS)的另一个平台上是否有共享和重建conda环境的好方法?平台(例如Windows)?

Is there a good method to share and recreate a conda environment in one platform (e.g. CentOS) in another platform (e.g. Windows)?

推荐答案

答案



此答案是假设您想确保
与您通常关心的软件包的相同版本位于
的不同平台上,并且您不关心$ b的完全相同的版本整个依赖树中的$ b all 个软件包。如果您试图在整个依赖项树中安装所有软件包的
完全相同版本,则失败可能性很高,因为某些conda软件包对osx / win / linux具有不同的
依赖关系。例如,
将在Win vs. osx / linux上安装不同的软件包,因此环境列表
会有所不同。

Answer

This answer is given with the assumption that you would like to make sure thatthe same versions of the packages that you generally care about are ondifferent platforms and that you don't care about the exact same versions ofall packages in the entire dependency tree. If you are trying to install theexact same version of all packages in your entire dependency tree that has ahigh likelihood of failure since some conda packages have differentdependencies for osx/win/linux. For example, the recipe forotroboptwill install different packages on win vs. osx/linux, so the environment listwould be different.

建议:手动创建一个environment.yaml文件,并仅指定或固定
您所关心的依赖项。
让conda求解器完成其余工作。
可能值得注意的是 conda-env (用于管理conda
环境的工具)明确建议您始终创建
environment.yml文件。

Recommendation: manually create an environment.yaml file and specify or pinonly the dependencies that you care about. Let the conda solver do the rest.Probably worth noting is that conda-env (the tool that you use to manage condaenvironments) explicitly recommends that you "Always create yourenvironment.yml file by hand."

然后,您只需执行 conda env创建--file environment.yml

看看
的自述文件。

它们可能非常简单:

name: basic_analysis
dependencies:
  - numpy
  - pandas

或更复杂的情况是,您需要固定依赖项并指定anaconda.org渠道从以下位置进行
安装:

Or more complex where you pin dependencies and specify anaconda.org channels toinstall from:

name: stats-web
channels:
  - javascript
dependencies:
  - python=3.4   # or 2.7 if you are feeling nostalgic
  - bokeh=0.9.2
  - numpy=1.9.*
  - nodejs=0.10.*
  - flask
  - pip:
    - Flask-Testing

无论哪种情况,都可以使用 conda env create --file environment.yaml创建一个环境。

In either case, you can create an environment with conda env create --file environment.yaml

如果您有更复杂的用例或其他问题,请更新原始的
问题,我看看是否可以帮助您多一点。

If you have a more complex use case or further questions, update the originalquestion and I'll see if I can help you a bit more.

这篇关于如何跨平台共享conda环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 22:34