conda fails to create environment from yml
Indeed environments keep platform build specifics under the conda-installed (i.e., dependencies
) section.
From OP's sample:
- zlib=1.2.11=hf3cbc9b_2
, hf3cbc9b_2
is a platform-specific version tag. You have to remove that.
If you do switch between platforms very often (OSX <-> Linux, for example), please read the answer from @merv, that is the right thing to do in your future env export
.
For the time being, like me, just want to have it fixed, you may do it manually or run a sed
over it:
sed 's/\(.*[[:alnum:]]\)=[[:alnum:]][[:alnum:].-_]*/\1/' environment.yml > env.yml
. That will handle the platform-specific tag without touching the pip
section of the file.
Then you can try again with env.yml
:
conda env create -f env.yml
Notice that platform-specific packages may occur. If after removing the version tags, Conda still complains, you'll have to manually clean the packages accordingly. For example, I'm bringing an
environment.yml
from Linux to Mac, where the packageslibgcc-ng=9.1.0
,libstdcxx-ng=9.1.0
,libgfortran-ng=7.3.0
are not defined; I removed them by hand.
Once such cleaning was done, my conda env create -f env.yml
worked like a charm.
No, PyPI is not the issue. Instead, it fails because the YAML includes platform-specific build constraints, but you are transferring across platforms. Specifically, examining the build numbers on the failed packages (e.g., six=py36h0e22d5e_1
), I can see that they correspond to packages from the osx-64
platform, but you are trying to install on a linux-64
platform, hence the build constraints are unresolvable.
Omit Build Info
The simplest solution to this is to omit the build info from the environment definition export.
conda env export -n py36 -f py36.yml --no-builds
There can still be issues if some of the packages are not available on linux-64
through Conda. If this is the case, you may need to find other channels (or check PyPI), switch versions, or remove the dependency altogether. Most of the packages look standard though.
Not so important, but you can safely remove cvxgrp
from your channels. That channel only serves an outdated version of cvxopt
and only for osx-64
.
Explicit Specifications Only
Another, even more loosely defined option, is to output only what Conda refers to as explicit specifications. These indicate only those requirements that have been explicitly requested by the user. This includes packages, but also captures any version constraints, etc., that were provided by the user at some point.
conda env export -n py36 -f py36.yml --from-history
The advantage here is that any platform-specific dependencies will be ignored.