Direct dependency conflict
Imagine you have an environment that you know will require Python 3.9, but you also want to installpackage-a
into that environment. You decide to specify version 2.0 of package-a
.
The only problem is, package-a
2.0 requires Python 3.10 or later (>=3.10
) and doesn’t have any backwards compatibility built into its version requirements.
If you try to install python
and package-a
into an environment with these exact requirements:
package-a
requires python
greater than or equal to version 3.10, but something is blocking that version from being installed.
Solving the version conflict
There are several strategies you can use to resolve a dependency version conflict.Create different environments
The safest approach is to create separate conda environments for conflicting packages. Based on the example above, ask yourself “If I need Python 3.9 in this environment, can I putpackage-a
in a different environment?”
Dependency resolution failures don’t always happen because of version incompatibilities. Sometimes you might be working with repositories where packages have been filtered out; for example, if you are using conda with a local package where packages have been filtered out for security or licensing reasons.In cases like these, sometimes there is no way to install a set of packages together with specific version constraints, even when using separate environments.
Only pin packages that require it
If specifying (or pinning) a version forpackage-a
along with python
is leading to solver errors, try only giving conda the name package-a
and no version number. This will give conda’s solver more options to evaluate.
package-a
, conda will attempt to find the latest possible version that works with Python 3.9.
Specify package ranges
Maybe you do want some control overpackage-a
’s version. In that case, try specifying a version range for package-a
.
When specifying a version range (with
<
, <=
, >
, or >=
), make sure you surround that part of the command in quotes.package-a
, conda will attempt to find a version older than 2.0 that works with Python 3.9.