在跨平台环境中管理conda env [英] Managing conda env in cross platform environment

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

问题描述

我的项目应该在跨平台环境(Mac,Win,Linux)上运行. 我创建了一个conda env来管理我们的依赖项,从而简化安装过程. 我想确保每个想要更新enn的人都可以这样做,但是当我尝试将env从linux导出到yml文件时,无法在Win或Mac上正确安装,反之亦然.

My project supposed to run on cross platform environment (Mac, Win, Linux). I've created a conda env that manage our dependencies for an easy setup. I want to ensure that everyone that want to update the enn could do that, however when I try to export the env from linux to yml file, it couldnt be install properly on Win or Mac and vise versa.

我已经尝试做常规的事情:

I've already tried to do the regular stuff:

1. conda env导出> env.yml
conda env创建--name -f env.yml

1. conda env export > env.yml
conda env create --name -f env.yml

2. conda env导出--no-builds> env.yml

2. conda env export --no-builds > env.yml

3. https://medium.com/@ Amet13/building-a-cross-platform-python-installer-using-conda-constructor-f91b70d393

4. https://tech.zegami.com/conda-constructor-tutorial-make-your-python-code-easy-to-to-install-cross-platform-f0c1f3096ae4

5. https://github.com/ESSS/conda-devenv/blob/master/README.rst

以上都不是给我正确的答案...我所附的一些教程可能会有所帮助,但是我未能成功实现它们,并且其中不包含一些用于完成本教程的重要信息适当地.

non of the above give me the right answer... some of the tutorials I've attached might help, but I didn't succeed to implement them correctly, and they didn't contain some important information for finishing the tutorial properly.

例如: 关于3/4-它没有解释如何创建应构造环境的yml文件.

for instance: Regarding 3/4 - It didn't explain how to create the yml file that should construct the env.

我了解到conda应该可以在跨平台环境中工作... 如果有人可以帮助我,那就太好了.

I understood that conda supposed to work on cross platform env... It would be great if someone could help me with that.

推荐答案

Conda Envs并非固有地跨平台

对不起,但是您要的不是什么. Conda可以将环境的程序包信息序列化为YAML(非常可再现),但是不能保证它将是跨平台的.实际上,许多软件包,尤其是使用非Python代码的软件包,需要使用不同的基础构建工具作为依赖项,因此您所要求的将永远无法满足.

Conda Envs are Not Inherently Cross-Platform

Sorry, but what you're asking for is simply not a thing. Conda can serialize an environment's package information to a YAML (great for reproducibility), but it can't guarantee that it will be cross-platform. In fact, many packages, especially ones with non-Python code, require different underlying build tools as dependencies, so what you're asking for will never be satisfied.

这几天您可以得到的最接近的结果是将environment.yaml限制为仅包含使用--from-history标志创建环境所使用的明确规范.此功能刚刚发布,因此您需要Conda 4.7.12或更高版本.

The closest you can get these days is to limit your environment.yaml to only include explicit specs that have gone into creating your environment by using the --from-history flag. This feature has only just been been released, so you need Conda 4.7.12 or later.

conda env export --from-history > environment.yaml

这将生成一个YAML,其中仅包含在环境历史记录中明确请求的软件包,例如,如果您的历史记录...

This will generate a YAML that only includes the packages that have been explicitly requested in the history of the env, e.g., if your history goes...

conda create -n foo python=3.7 numpy
conda install -n foo pandas scikit-learn

然后conda env export -n foo --from-history的结果将类似于

name: foo
channels:
  - defaults
dependencies:
  - python=3.7
  - numpy
  - pandas
  - scikit-learn
prefix: /your/conda/dir/envs/foo

通过这种方式,您可以省去可能与平台相关的所有其他依赖项.

This way, you can leave out all the other dependencies that may turn out to be platform-specific.

我注意到,如果您曾经在环境中使用--update-deps标志,则会将每个依赖项添加为明确的规范.这是很不幸的.如果是这种情况,我建议您使用合法的规范重新创建环境,并在以后避免使用该标志.搜索您的命令历史记录对于编译该合法规范列表可能会很有用.

I've noticed that if you ever use the --update-deps flag in an env, it adds every dependency to being an explicit spec. This is rather unfortunate. If this is the case, I'd suggest recreating the env using your legitimate specs and avoid that flag in the future. Searching through your command history might be useful in compiling that legitimate spec list.

这篇关于在跨平台环境中管理conda env的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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