'creating conda venv: conda env create VS conda env update

When creating conda virtual environment with YAML file for the first time, I unknowingly ran:

conda env update -f environment.yml
call activate process_name

which successfully created a venv in: C:\Users\userName\AppData\Local\Continuum\anaconda3\envs.

Should I have ran the following instead?

conda env create -f environment.yml
call activate process_name

Does conda env update create a new venv if no existing venv is found in the anaconda envs directory?

How stable is conda env update in defaulting to creating a new venv if no existing venv is found?



Solution 1:[1]

Both should work to create the new venv if such an environment doesn't exists. You can easily try this with a sample environment.yml

Create the following environment.yml file in a directory of your choice:

name: testenv123
dependencies:
  - python
  - pytorch

and then run this:

conda env update
activate testenv123

Solution 2:[2]

Does conda env update create a new venv if no existing venv is found in the anaconda envs directory?

Yes

How stable is conda env update in defaulting to creating a new venv if no existing venv is found?

I could not find any documentation stating that it will create a new environment if the environment does not already exist. Therefore I think that there are no guarantees about this behavior staying the same in the future.

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 sin2akshay
Solution 2 mareoraft