Conda - search for package, specify Python version

Viewed 55

I'm trying to search for a package, specifying the Python version. I have tried:

# Find Python 2.7 packages for 'numpy'
conda search "numpy=py27_0" --info
No match found for: numpy=py27_0. Search: *numpy*=py27_0

conda search "numpy==py27_0" --info
No match found for: numpy==py27_0. Search: *numpy*==py27_0

How can I specify the Python version, e.g. 2.7, 3.6?

1 Answers

There isn't a direct mechanism to constrain Python version outside of running the actual solver. However, the major channels use the Python version (say 3.8) to generate a string (say "py38") that is included in the build string. This can thus be used as proxy, by searching for constraints on the build string. For example, the following (equivalent) expressions should pick up all Python 2.7 builds of numpy in the configured channels:

## search all versions with 'py27' build string
conda search 'numpy=*=*py27*'

## alternative (MatchSpec) syntax
conda search 'numpy[build=*py27*]'

The first version must explicitly specify the version as unconstrained ("*"); the latter directly specifies the build constraint, with the unconstrained version implied.

Related