Conda env export includes prefix path and platform-specific build strings
0 reputation · 17 Jul 2022, 03:22 UTC
0 reputation · 17 Jul 2022, 03:22 UTC
Goal: determine whether output from `conda env export` can serve as a cross-platform production deployment artifact, or whether it should be treated only as a local snapshot of one environment.
The exported YAML embeds the active conda prefix path and platform-specific build strings. Channel defaults and priority may differ between workstations and production, which can change resolution results even with the same file. The `--from-history` flag omits transitive dependencies, so a recreated environment may lack runtime packages. Conda does not enforce cross-platform validity of the exported file.
Open questions:
conda env export produces a local environment snapshot. It embeds the absolute prefix path (e.g., /home/user/miniconda3/envs/myenv) and platform-specific build strings (e.g., numpy-1.24.3-py39h5a1b2c3_0) that encode OS, architecture, and compiler details. Because channel configuration and priority are not fully captured, resolution can differ across machines even with the same YAML. Therefore, the exported file should not be used as a cross-platform production deployment artifact without transformation.
channel_priority are not locked; the same spec can resolve to different package sets over time or on different hosts.--from-history limitation – exports only explicitly requested packages, omitting transitive dependencies. Recreated environments often miss required runtime libraries, breaking applications.environment.yml with version-pinned dependencies but without build strings (e.g., numpy=1.24.3).conda-lock to generate platform-specific lock files:
conda-lock lock -f environment.yml --kind=explicit --platform linux-64 --platform osx-64 --platform win-64
This produces immutable conda-linux-64.lock, conda-osx-64.lock, etc., that record exact package URLs and hashes.conda create -n prod --file conda-linux-64.lockconda-lock with --kind=explicit to create fully self-contained artifacts immune to channel drift.conda env export and inspect the YAML for prefix: and build-string suffixes (e.g., py39h123456_0).conda env export vs conda env export --from-history to see missing transitive dependencies.conda env create -f exported.yml in a Docker container for a different OS/architecture to observe resolution failures.conda-lock and verify they install cleanly on each target platform.If your production targets a single, identical OS/architecture (e.g., only Linux x86_64) and you control the channel configuration on all hosts, you can strip the prefix: line and use the exported YAML directly—though conda-lock remains safer for long-term reproducibility. For mixed platforms, lock files are mandatory.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.