How to Set Up VS Code for Data Science and AI - Ultimate Guide
Last Updated :
10 Feb, 2025
Visual Studio Code (VS Code) is a powerful, lightweight, and extensible code editor that is widely used for data science and AI projects due to its ability to handle Python, Jupyter notebooks, and more within a single environment. When combined with Anaconda, it becomes an even more robust tool for managing environments, dependencies, and workflows. In this ultimate guide, we’ll walk through the process for setting up VS code via : primary method using Anaconda Navigator and an alternative approach.
Prerequisites: Before diving into configuration, the first step is to download and install VS Code and anaconda.
Method 1: Using Anaconda Navigator
This method uses Anaconda Navigator to create a virtual environment and launch VS Code.
Step 1: Create a New Folder in your file manager ( local )
For eg, name it testing
We will use this folder later for navigating.
Step 2: Open Anaconda Navigator
- Launch Anaconda Navigator from your system’s applications menu.
Step 3: Launch VS Code
- In Anaconda Navigator, find VS Code in the list of applications and click Launch.
Anaconda NavigatorStep 3: Open the folder, that you created in Step 1
Go to file > Click on Open a folder
Step 4: Create a Virtual Environment
- Open a new terminal in VS Code (
Ctrl +
or go to Terminal > New Terminal
). - Run the following command to create a virtual environment:
conda create -p venv python==3.12
Here, -p venv
specifies the environment name and location, and python==3.12
sets the Python version.
Step 4: Confirm Environment Creation
- When prompted, type
y
and press Enter to confirm the creation of the environment.
Virtual EnvironmentStep 5: Activate the Environment
- Activate the environment using:
conda activate
Activate the EnvironmentStep 6: Check for conda version or type conda info
conda versionStep 7: Install Python Extension
- Go to the Extensions tab in VS Code (or press
Ctrl + Shift + X
). - Search for the Python extension by Microsoft and install it.
Method 2: Using VS Code Directly
This method involves creating a virtual environment directly in VS Code without using Anaconda Navigator.
Step 1: Create a New Folder
- Create a new folder on your local machine for your project.
Step 2: Setting Up Your Workspace in VS Code
- Open VS Code and go to
File > Open Folder
to open the folder you just created. - Save the folder as a workspace file (
File > Save Workspace As
). This creates a .code-workspace file for the project.
Step 3: Create a Virtual Environment
- Open the Command Palette (
Ctrl + Shift + P
) and search for Python: Create Environment. - Select Venv as the environment type and choose Python 3.12 as the interpreter.
Step 4: Install Python Extension
- If you haven’t already, install the Python extension from the Extensions tab.