gpt4 book ai didi

python - 如何跨平台共享 conda 环境

转载 作者:IT老高 更新时间:2023-10-28 20:35:33 26 4
gpt4 key购买 nike

http://conda.pydata.org/docs/using/envs.html 上的 conda 文档解释如何与其他人共享环境。

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

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)中在另一个平台(例如 Windows)中共享和重新创建 conda 环境?

最佳答案

这个答案是假设你想确保您通常关心的软件包的相同版本在不同的平台,你不关心完全相同的版本all 整个依赖树中的包。如果您尝试安装整个依赖关系树中所有包的完全相同版本,具有失败的可能性很高,因为一些 conda 包有不同的osx/win/linux 的依赖项。例如,the recipe forotrobopt将在 Win vs. osx/linux 上安装不同的包,所以环境列表会有所不同。

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

那你就做 conda env create --file environment.yml

查看自述文件 conda-env .

它们可以很简单:

name: basic_analysis
dependencies:
- numpy
- pandas

或者更复杂的地方,你固定依赖项并指定 anaconda.org channel 安装位置:

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 创建环境。

注意:如果您使用的是旧版本的 conda,您可能需要使用 .* 作为版本后缀。

关于python - 如何跨平台共享 conda 环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39280638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com