'How to modify .condarc file or use pinning to force conda to install the noarch selenium version when running "conda update --all"?

I would like to install selenium v4.1.0 on Anaconda python on Windows.

https://anaconda.org/conda-forge/selenium

If you run conda install selenium, conda will install selenium v3.11 if you're on Windows.

I ran conda install selenium --channel conda-forge/noarch to make conda install selenium v4.1.0 which is the noarch version.

The problem is when I run conda update --all, conda will downgrade my selenium back to v3.

After some googling, I discover modifying the config file .condarc may fix this problem. Question is how to modify .condarc to force conda to install the noarch selenium version when running "conda update --all"?

I am open to other solutions like pinning that will prevent conda from downgrading selenium back to v3 when I run conda update --all

I'm using python 3.9.12, conda 4.12.0



Solution 1:[1]

As @merv mentioned pin your package, which is a little unclear in the linked post. Open the anaconda3 directory, go into conda-meta subfolder and create a file called pinned. Inside the file add 1 line: selenium>=4.1.0 and test again. If you have an environment setup go into anaconda3\envs and inside the correct environment folder, go into the conda-meta folder there and save your pinned file. I tested it and it would keep the selenium>=4.1.0 using this method after doing a conda update --all

If you open Anaconda Prompt and type: where python it will usually show your installation directory, in case you don't know where it installed to.

Solution 2:[2]

Conda has a sufficiently expressive specification grammar (called MatchSpec) to handle this - no need to mess around with .condarc.

conda install "conda-forge::selenium[version='>=4.1']"

It is possible that there are conflicts with the current environment, in which case, consider creating a new environment with Python 3.7 or later.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matt
Solution 2 merv