> ## Documentation Index
> Fetch the complete documentation index at: https://anaconda.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Visual Studio Code (VS Code)

export const Comments = ({children}) => {
  return <div class="my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-zinc-500/20 bg-zinc-50/50 dark:border-zinc-500/30 dark:bg-zinc-500/10" data-callout-type="comments">
      <div class="w-4">
        <svg width="14" height="14" viewBox="0 0 640 640" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" aria-label="Comments">
            <path d="M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM280 400C266.7 400 256 410.7 256 424C256 437.3 266.7 448 280 448L360 448C373.3 448 384 437.3 384 424C384 410.7 373.3 400 360 400L352 400L352 312C352 298.7 341.3 288 328 288L280 288C266.7 288 256 298.7 256 312C256 325.3 266.7 336 280 336L304 336L304 400L280 400zM320 256C337.7 256 352 241.7 352 224C352 206.3 337.7 192 320 192C302.3 192 288 206.3 288 224C288 241.7 302.3 256 320 256z" />
        </svg>
      </div>
      <div class="text-sm prose min-w-0 w-full">
        {children}
      </div>
    </div>;
};

<Note>
  These instructions refer to Anaconda Distribution exclusively, but will also work with Miniconda.
</Note>

[Visual Studio Code (VS Code)](https://code.visualstudio.com) is a free, cross-platform source code editor that works with Anaconda Distribution and Miniconda. Installing the [Python for Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) enables VS Code to connect to a <Tooltip tip="An isolated folder containing specific conda packages and dependencies that won't interfere with other projects. Each environment maintains its own versions of libraries and packages, so changes in one environment don't affect others.">conda environment</Tooltip>'s version of Python as an interpreter for your Python code files.

<Tip>
  More of a visual learner? [Sign in to Anaconda.com](https://auth.anaconda.com/ui/login?return_to=https://anaconda.com/app/) and enroll in our Get Started with Anaconda course to learn to [create a simple Python program with VS Code](https://learning.anaconda.com/courses/take/get-started-with-anaconda/lessons/63332024-create-a-simple-python-program-in-vs-code).
</Tip>

## Launching VS Code in Navigator

With VS Code installed, you can launch the application from [Navigator](/tools/anaconda-navigator/main) 1.9.12 or later by clicking the VS Code tile on the **Home** page.

When you launch VS Code from Navigator, it will automatically use the Python interpreter in the currently selected environment.

## Creating a conda environment in VS Code

Before starting your Python project, Anaconda recommends creating a conda environment to isolate your project's software packages and manage their dependencies.

<Note>
  You must have the [Python for Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) installed to create new conda environments from within VS Code on Windows.
</Note>

1. Open the Command Palette by pressing Ctrl+Shift+P (Windows, Linux)/Cmd+Shift+P (Mac).
2. Select "**Conda** Creates a \`.conda\` Conda environment in the current workspace."
3. Select the Python version you'd like install in the environment.

Alternatively, you can [create a new environment](/getting-started/working-with-conda/environments#creating-an-environment) with Anaconda Prompt (Terminal in macOS/Linux), and then select the environment in VS Code as the workspace's [Python interpreter](#selecting-anaconda-as-a-python-interpreter).

For more information about managing environments with conda, see the [official conda documentation](https://docs.conda.io/projects/conda/en/stable/user-guide/tasks/manage-environments.html).

For more information about Python environments in VS Code, see the [official VS Code documentation](https://code.visualstudio.com/docs/python/environments).

## Selecting Anaconda as a Python interpreter

Now that your conda environment has been created, select the environment as an interpreter. This ensures that your code has access to the correct code completion and type information available in the specific Python version and packages installed in your conda environment.

1. Open any Python file.
2. To select a Python interpreter, open the Command Palette by pressing Ctrl+Shift+P (Windows, Linux)/Cmd+Shift+P (Mac).
3. Click *Python: Select Interpreter* in the Command Palette and select the interpreter associated with your Anaconda environment.

<Tip>
  Anaconda interpreter typically appears as Python. 3.x.x (`<YOUR_ENV_NAME>`: conda). If your environment's interpreter does not appear in the Select Interpreter list, click **Refresh**.
</Tip>

You can also manually enter an interpreter path by selecting **Enter interpreter path…**.

For more information on finding a specific interpreter path in your Anaconda installation, see [Finding your Anaconda Python interpreter path](/getting-started/guides/ides/python-path).

The selected interpreter displays in the bottom right corner of the status bar in VS Code.

<Frame>
  <img src="https://mintcdn.com/anaconda-29683c67/hMeu-8dEYFekrhE_/images/VSC_python_interpreter.png?fit=max&auto=format&n=hMeu-8dEYFekrhE_&q=85&s=27aafc3f945210798ce73d9b1f01c071" alt="" width="2798" height="566" data-path="images/VSC_python_interpreter.png" />
</Frame>

## Adding packages to your environment

To add packages to your environment in VS Code:

1. Open a new terminal by pressing Ctrl+\`.
2. Run the following command:

```sh theme={null}
conda install <PACKAGE_NAME>
```

<Comments>
  Replace \<PACKAGE\_NAME> with the name of the package you want to install.
</Comments>

<Note>
  On Windows, you can run conda commands in both Powershell and Command Prompt terminals in VS Code.

  <Frame>
    <img src="https://mintcdn.com/anaconda-29683c67/kBuj3mPdZoBk8YoG/images/vscode-package-install.png?fit=max&auto=format&n=kBuj3mPdZoBk8YoG&q=85&s=94abfc4edc20aa693880de0080b9d29f" alt="" width="2238" height="438" data-path="images/vscode-package-install.png" />
  </Frame>

  When you select the new environment, you may see a notification that says, "Selected conda environment was successfully activated, even though '(.conda)' indicator may not be present in the terminal prompt." You can still run conda commands in the terminal. See VS Code's official documentation for more information on [activating environments in terminal](https://github.com/microsoft/vscode-python/wiki/Activate-Environments-in-Terminal-Using-Environment-Variables).
</Note>

Learn more about adding [conda packages](/getting-started/working-with-conda/packages/install-packages) to environments.

## Testing your setup

You are now ready to execute your Python functions in VS Code!

1. Create a new Python (.py) file.

2. Add the following code to your file:

   ```sh theme={null}
   # This will display "Hello, World!" in the terminal
   print("Hello, World!")

   # This will display your system version in the terminal
   import sys
   print(sys.version)
   ```

3. Save the file.

4. Click  <Icon icon="play" iconType="regular" /> **Run Python File**.

<Frame>
  <img src="https://mintcdn.com/anaconda-29683c67/hMeu-8dEYFekrhE_/images/VSC_python_run.png?fit=max&auto=format&n=hMeu-8dEYFekrhE_&q=85&s=19eba349c4fb9c1c2e8ad6721c6aa5b1" alt="" width="2470" height="1746" data-path="images/VSC_python_run.png" />
</Frame>

For more information on working with Python in VS Code, see [Python in Visual Studio Code](https://code.visualstudio.com/docs/languages/python).
