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

查看:25
本文介绍了在跨平台环境中管理 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 create --name -f env.yml

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

2.conda env export --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-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 - 它没有解释如何创建应该构造 env 的 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 v4.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 requires Conda v4.7.12 or later.

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

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

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 的结果将类似于

Then the result of conda env export -n foo --from-history will be something like

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 标志,它会将每个依赖项添加为显式规范.这是比较不幸的.如果是这种情况,我建议您使用您的合法规范重新创建 env,并在将来避免使用该标志.搜索您的命令历史可能有助于编译该合法规范列表.

I've noticed that if one ever uses 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天全站免登陆