Install a specific package version using conda (anaconda)

avatar
Borislav Hadzhiev

Last updated: Apr 10, 2024
3 min

banner

# Install a specific package version using conda (anaconda)

Use the conda install package=version command to install a specific version of a package using conda, e.g. conda install scipy=1.9.1.

You can also install a package version of at least X or a version not greater than Y by wrapping the name of the package and the version in quotation marks.

shell
conda install scipy=1.9.1 # 👇️ Install scipy version 1.7.1 or higher conda install "scipy>=1.7.1" # 👇️ Install scipy version prior to 1.7.1 conda install "scipy<1.7.1"

conda install specific package version

The syntax for installing a specific version of a package using anaconda is conda install package=version.

# Specify the environment when installing a package

You can also specify the environment when installing a specific version of the package.

Use the conda env list command to list your environments.

shell
conda env list

conda list environments

Use the --name option to specify the environment when installing the package.

shell
conda install --name myenv scipy=1.9.1

specify environment when installing specific version

Here is an example of installing at least version 1.7.1 of scipy.

shell
conda install "scipy>=1.7.1"

Note that the package name and version are wrapped in double quotes.

Quotation marks must be used when the specification contains a space or any of the following characters: <, >, |, *.

# Installing a version prior to version X

Something you might commonly have to do is install the version of a package before version X.

shell
conda install "scipy<1.7.1"

install version prior to version x

If you want to not be prompted for confirmation when installing a package, use the -y option.

shell
conda install -y "scipy<1.7.1"

# List all available versions of a package

You can list all available package versions with the conda search -f <package> command.

shell
conda search -f scipy

You can also search for a specific version of a package.

shell
conda search "scipy>1.7"
The command lists the available versions of scipy that are greater than version 1.7.

# Specifying a version range

You can also specify a version range of the package to be installed using conda.

shell
conda install "scipy>=1.7,<1.9"

specifying version range

The command installs version 1.7, 1.8, but not 1.9.

Notice that there is a comma between the two versions.

You can also use the OR operator to install version X or version Y.

shell
conda install "scipy=1.9.1|1.9.2"

install version x or version y

The command installs version 1.9.1 or version 1.9.2 of scipy.

I've also written a detailed guide on how to pip install a specific version of a Python package.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.