---
title: Windows + VS Code + (Ana)conda
tags: PythonSetup
---
# How to use a `conda`-based Python environment in VS Code on Windows?
Experience has shown that on Windows some users run into problems.
This document outlines a suggested setup and discusses "test cases" so you can verify that your setup is working correctly.
Please provide feedback by writing a comment below.
## Issues at Play
There may be different issues at play making it difficult to pinpoint the exact source
of the problem without knowing more details.
Some causes include:
- How was `conda` installed?
- Is `conda` added to the `PATH` environment variable (e.g. during installation)?
- Different prompts/shells with different configurations:
- Windows command prompt
- Windows powershell
- Anaconda command prompt
- Terminal within VS Code
- How is VS Code configured?
- How is the Python path set?
- How is the terminal configured?
- ...
- Changes in default settings over time.
- ...
See also:
- [Python in VS Code (official docs)](https://code.visualstudio.com/docs/languages/python)
- [VS Code and Anaconda (official docs)](https://docs.anaconda.com/anaconda/user-guide/tasks/integration/vscode/)
- [Working with Anaconda in Visual Studio Code (SO)](https://stackoverflow.com/questions/54828713/working-with-anaconda-in-visual-studio-code)
- [Using Python with Anaconda and Visual Studio Code (Windows) (YT)](https://www.youtube.com/watch?v=3Wt00qGlh3s)
- [VS Code missing from Home Page (GH)](https://github.com/ContinuumIO/anaconda-issues/issues/11640)
### 0. Prepare a test environment
See the beginning of this [guide](https://hackmd.io/@caichinger/BJ2og5bNF).
### 1. Install VS Code
[Download and install VS Code.](https://code.visualstudio.com/Download)
Launch VS Code.
Within VS Code, type `Ctrl+Shift+X` to install the following extensions by
typing their name into the text field:
* Python
* Jupyter
### 2. Install Anaconda Python Distribution
We require the package manager `conda` and the [Anaconda Navigator](https://anaconda.org/anaconda/anaconda-navigator) as graphical user interface.
**Option A**
[Download and install Anaconda distribution keeping the default settings.](https://docs.anaconda.com/anaconda/install/windows/)
**Option B**
Alternatively, this means you can as well:
- Install `conda` through the [Miniconda installer](https://docs.conda.io/en/latest/miniconda.html)
- Use Anaconda prompt to [install the navigator](https://anaconda.org/anaconda/anaconda-navigator)
```console
$ conda activate base
$ conda install -c anaconda anaconda-navigator
```
### 3. Create a `conda` Environment
**Option A**
Launch Anaconda Navigator from the start menu.
Within the navigator, create an environment by doing
1. Environment
2. Import
3. Select "Specification File", i.e. browse and select `environment.yml`
file created above
If you do not see the navigator in the start menu, you can launch
it from the command line
```console
$ conda activate base
$ anaconda-navigator
```
**Option B**
Alternatively, using Anaconda prompt (start menu) run
```console
$ conda env create -f environment.yml
```
### 4. Launch VS Code using the `conda` environment
Launch VS Code through Anaconda Navigator.
Anaconda navigator displays VS Code as an application (if not, see [here](https://github.com/ContinuumIO/anaconda-issues/issues/11640)).
In the "Applications on" dropdown menu on the home screen, select our *testenv*
environment and then launch VS Code by clicking the respective button.
### 5. Verify that it works
See the end of this [guide](https://hackmd.io/@caichinger/BJ2og5bNF).
## To keep in mind
- The location of the folder and the `conda` environment you use are not
related to each other. You can use whatever `conda` environment in whatever
folder.
- Once created, there is no persisitng relationship between the environment
file and `conda` environment that was created from the file.
- Activating a `conda` environment in an terminal and then launching VS Code from that terminal has no effect on how VS Code is configured.
## Comments
Did it work for you? Please explain to help us better understand the problem.