Skip to content

Commit df305af

Browse files
Merge pull request #8340 from MicrosoftDocs/users/jukullam/anaconda-updates
Update Anaconda documentation for clarity and accuracy
2 parents 2e56fac + f6530fc commit df305af

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

docs/pipelines/ecosystems/anaconda.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Run pipelines with Anaconda environments
33
description: Set up and use Anaconda environments with Azure Pipelines, Azure DevOps
4-
ms.topic: quickstart
4+
ms.topic: how-to
55
ms.assetid: 50ed6bb4-5f35-4e1e-aafc-295eb10198df
6-
ms.date: 01/24/2022
6+
ms.date: 09/23/2025
77
monikerRange: azure-devops
88
author: JuliaKM
99
---
@@ -12,7 +12,16 @@ author: JuliaKM
1212

1313
[!INCLUDE [version-eq-azure-devops](../../includes/version-eq-azure-devops.md)]
1414

15-
Learn how to set up and use Anaconda with Python in your pipeline. Anaconda is a Python distribution for data science and machine learning.
15+
Set up and use Anaconda with Python in your pipeline. Anaconda is a Python distribution for data science and machine learning.
16+
17+
## Prerequisites
18+
19+
Python is preinstalled on [Microsoft-hosted agents](../agents/hosted.md) for Linux, macOS, and Windows. You don't have to set up anything more to build Python projects. To see which Python versions are preinstalled, see [Software](../agents/hosted.md#software).
20+
21+
| **Product** | **Requirements** |
22+
|---|---|
23+
| **Azure DevOps** | - An [Azure DevOps project](../../organizations/projects/create-project.md).<br> - An ability to run pipelines on Microsoft-hosted agents. You can either purchase a [parallel job](../licensing/concurrent-jobs.md) or you can request a free tier. <br> - Basic knowledge of YAML and Azure Pipelines. For more information, see [Create your first pipeline](../create-first-pipeline.md). <br> - **Permissions:**<br> &nbsp;&nbsp;&nbsp;&nbsp; - To create a pipeline: you must be in the **Contributors** group and the group needs to have *Create build pipeline* permission set to Allow. Members of the [Project Administrators group](../../organizations/security/permissions.md) can manage pipelines. <br> &nbsp;&nbsp;&nbsp;&nbsp;- To create service connections: You must have the *Administrator* or *Creator* role for [service connections](../library/add-resource-protection.md).
24+
| **GitHub** | - A [GitHub](https://github.com) account. <br> - A [GitHub service connection](../library/service-endpoints.md) to authorize Azure Pipelines.|
1625

1726
## Get started
1827

@@ -28,18 +37,18 @@ Follow these instructions to set up a pipeline for a sample Python app with Anac
2837

2938
1. When the list of repositories appears, select your Anaconda sample repository.
3039

31-
1. Azure Pipelines will analyze the code in your repository and detect an existing `azure-pipelines.yml` file.
40+
1. Azure Pipelines analyzes the code in your repository and detects an existing `azure-pipelines.yml` file.
3241

3342
1. Select **Run**.
3443

3544
1. A new run is started. Wait for the run to finish.
3645

3746
> [!TIP]
38-
> To make changes to the YAML file as described in this topic, select the pipeline in the **Pipelines** page, and then **Edit** the `azure-pipelines.yml` file.
47+
> To make changes to the YAML file as described in this article, select the pipeline in the **Pipelines** page, and then **Edit** the `azure-pipelines.yml` file.
3948
4049
## Add conda to your system path
4150

42-
On [hosted agents](../agents/hosted.md), conda is left out of `PATH` by default to keep its Python version from conflicting with other installed versions. The `task.prependpath` agent command will make it available to all subsequent steps.
51+
On [hosted agents](../agents/hosted.md), conda isn't included in `PATH` by default to prevent its Python version from conflicting with other installed versions. Use the `task.prependpath` agent command to make conda available to all later steps.
4352

4453
# [Ubuntu](#tab/ubuntu)
4554

@@ -56,8 +65,8 @@ Use the `macOS-latest` agent with Anaconda.
5665
- bash: echo "##vso[task.prependpath]$CONDA/bin"
5766
displayName: Add conda to PATH
5867
59-
# On Hosted macOS, the agent user doesn't have ownership of Miniconda's installation directory/
60-
# We need to take ownership if we want to update conda or install packages globally
68+
# On hosted macOS, the agent user doesn't own Miniconda's installation directory.
69+
# Take ownership if you want to update conda or install packages globally.
6170
- bash: sudo chown -R $USER $CONDA
6271
displayName: Take ownership of conda installation
6372
```
@@ -75,7 +84,7 @@ Use the `macOS-latest` agent with Anaconda.
7584

7685
### From command-line arguments
7786

78-
The `conda create` command will create an environment with the arguments you pass it.
87+
The `conda create` command creates an environment with the arguments you pass.
7988

8089
# [Ubuntu](#tab/ubuntu)
8190

@@ -99,7 +108,7 @@ The `conda create` command will create an environment with the arguments you pas
99108
```
100109

101110
> [!NOTE]
102-
> To add specific conda channels, you need to add an extra line for conda config:
111+
> To add specific conda channels, add an extra line for conda config:
103112
> `conda config --add channels conda-forge`
104113

105114

@@ -115,15 +124,10 @@ You can check in an [`environment.yml`](https://conda.io/docs/user-guide/tasks/m
115124
```
116125

117126
> [!NOTE]
118-
> If you are using a self-hosted agent and don't remove the environment at the end, you'll get an
119-
> error on the next build since the environment already exists. To resolve, use the `--force`
120-
> argument: `conda env create --quiet --force --file environment.yml`.
127+
> If you use a self-hosted agent and don't remove the environment at the end, you get an error on the next build because the environment already exists. To fix this, remove the environment before creating a new one with `conda env remove --name your-env-name`.
121128

122129
> [!NOTE]
123-
> If you are using self-hosted agents that are sharing storage, and running jobs in parallel
124-
> using the same Anaconda environments, there may be clashes between those environments.
125-
> To resolve, use the `--name` argument and a unique identifier as the argument value,
126-
> like a concatenation with the `$(Build.BuildNumber)` build variable.
130+
> If you use self-hosted agents that share storage and run jobs in parallel using the same Anaconda environments, there can be clashes between those environments. To fix this, use the `--name` argument and a unique identifier as the argument value, like a concatenation with the `$(Build.BuildNumber)` build variable.
127131

128132
### Install packages from Anaconda
129133

@@ -133,7 +137,7 @@ The following YAML installs the `scipy` package in the conda environment named `
133137

134138
```yaml
135139
- bash: |
136-
source activate myEnvironment
140+
conda activate myEnvironment
137141
conda install --yes --quiet --name myEnvironment scipy
138142
displayName: Install Anaconda packages
139143
```
@@ -142,7 +146,7 @@ The following YAML installs the `scipy` package in the conda environment named `
142146

143147
```yaml
144148
- bash: |
145-
source activate myEnvironment
149+
conda activate myEnvironment
146150
conda install --yes --quiet --name myEnvironment scipy
147151
displayName: Install Anaconda packages
148152
```
@@ -162,14 +166,14 @@ The following YAML installs the `scipy` package in the conda environment named `
162166

163167
> [!NOTE]
164168
> Each build step runs in its own process.
165-
> When you activate an Anaconda environment, it will edit `PATH` and make other changes to its current process.
166-
> Therefore, an Anaconda environment must be activated separately for each step.
169+
> When you activate an Anaconda environment, it edits `PATH` and makes other changes to its current process.
170+
> So, activate an Anaconda environment separately for each step.
167171

168172
# [Ubuntu](#tab/ubuntu)
169173

170174
```yaml
171175
- bash: |
172-
source activate myEnvironment
176+
conda activate myEnvironment
173177
python -m pytest --junitxml=junit/unit-test.xml
174178
displayName: pytest
175179
@@ -183,7 +187,7 @@ The following YAML installs the `scipy` package in the conda environment named `
183187

184188
```yaml
185189
- bash: |
186-
source activate myEnvironment
190+
conda activate myEnvironment
187191
pytest --junitxml=junit/unit-test.xml
188192
displayName: pytest
189193
@@ -209,18 +213,19 @@ The following YAML installs the `scipy` package in the conda environment named `
209213

210214
---
211215

212-
## FAQs
216+
217+
## FAQ
213218

214219
### Why am I getting a "Permission denied" error?
215-
On Hosted macOS, the agent user does not have ownership of the directory where Miniconda is installed.
216-
For a fix, see the "Hosted macOS" tab under [Add conda to your system path](#add-conda-to-your-system-path).
220+
On hosted macOS, the agent user doesn't own the directory where Miniconda is installed.
221+
To fix this issue, go to the "Hosted macOS" tab under [Add conda to your system path](#add-conda-to-your-system-path).
217222

218223
### Why does my build stop responding on a `conda create` or `conda install` step?
219-
If you forget to pass `--yes`, conda will stop and wait for user interaction.
224+
If you don't pass `--yes`, conda stops and waits for user input.
220225

221226
### Why is my script on Windows stopping after it activates the environment?
222227
On Windows, `activate` is a Batch script. You must use the [`call`](/windows-server/administration/windows-commands/call) command to resume running your script after activating.
223228
See examples of using `call` [in a pipeline](#run-pipeline-steps-in-an-anaconda-environment).
224229

225230
### How can I run my tests with multiple versions of Python?
226-
See [Build Python apps in Azure Pipelines](./python.md).
231+
Go to [Build Python apps in Azure Pipelines](./python.md).

0 commit comments

Comments
 (0)