Create from environment.yml#
This tutorial creates a regular named conda environment from a project-root
environment.yml.
Before you start#
Complete the Quickstart. Open a local folder named
conda-code-demo in VS Code and register it as a Python project.
Make sure no environment with that name already exists:
conda info --envs
Add the environment file#
Create environment.yml at the project root:
name: ignored-by-conda-code
dependencies:
- python
- pytest
The file follows
CEP 24. Conda Code supplies the
environment name itself, so the name in the file does not control the created
environment. Conda uses the channels configured for the selected installation.
Create the environment#
Open
environment.ymlin the editor.Choose the Conda Code: Create Environment from File action in the editor title.
Conda Code creates a named environment called conda-code-demo. If that name is
already used, it adds a numeric suffix. When creation finishes, the environment
appears as the selected environment for conda-code-demo in the Python
Environments view.
Create through Python Environments instead
Open the Python Environments view.
Start Quick Create for the project.
Select Conda Code if VS Code asks for an environment manager.
Quick Create finds the single project input and creates the same named environment.
Inspect the result:
conda list --name conda-code-demo
The environment contains Python and pytest from the file.
Change the installed environment#
Open Manage Packages for the environment and install ruff.
conda list --name conda-code-demo ruff
The package is installed in the prefix. environment.yml is unchanged.
What happened#
Conda Code ran
conda create --yes --json --name conda-code-demo --file environment.yml from
the project root. The file was a one-time creation input. The resulting
environment is an ordinary named conda environment selected for the project, so
later package operations use regular conda commands.