These instructions refer to Anaconda Distribution exclusively, but will also work with Miniconda.
More of a visual learner? Sign in to Anaconda.com and enroll in our Get Started with Anaconda course. See the Create a simple Python program with VS Code lesson in the Hands-on Practice section.
Launching VS Code in Navigator
With VS Code installed, you can launch the application from Navigator 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.You must have the Python for Visual Studio Code extension installed to create new conda environments from within VS Code on Windows.
- Open the Command Palette by pressing Ctrl+Shift+P (Windows, Linux)/Cmd+Shift+P (Mac).
- Select “Conda Creates a `.conda` Conda environment in the current workspace.”
- Select the Python version you’d like install in the environment.
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.- Open any Python file.
- To select a Python interpreter, open the Command Palette by pressing Ctrl+Shift+P (Windows, Linux)/Cmd+Shift+P (Mac).
- Click Python: Select Interpreter in the Command Palette and select the interpreter associated with your Anaconda environment.
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.
Adding packages to your environment
To add packages to your environment in VS Code:- Open a new terminal by pressing Ctrl+`.
- Run the following command:
On Windows, you can run conda commands in both Powershell and Command Prompt terminals in VS Code.
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.

Testing your setup
You are now ready to execute your Python functions in VS Code!- Create a new Python (.py) file.
-
Add the following code to your file:
- Save the file.
- Click Run Python File.
