Set Up Python and VS Code for Data Science, Step by Step

Install Miniconda and Visual Studio Code, give each project its own clean environment, and run your first Jupyter notebook — with a screenshot for every click.

Before you can analyse data, clean a dataset or train a model, you need a Python setup that simply works. The good news: modern package managers have made this far less painful than it used to be. This guide walks you from an empty machine to a working notebook in four stages, with a screenshot at every step.

Here's the toolkit we'll put together:

  • Miniconda installs Python and manages the packages each project needs.
  • Visual Studio Code is the editor where you'll write and run your code.
  • A conda environment gives each project its own isolated set of packages.

What we'll cover

  1. Install Miniconda
  2. Install VS Code and its Python extension
  3. Create a dedicated environment for your project
  4. Run a notebook to confirm everything works

1. Install Miniconda

Step 1.1: Head to the Miniconda download page and pick the installer for your operating system. Choose one that ships with Python 3.8 or newer, and match your system type (64-bit for almost every modern computer).

Miniconda is the slimmed-down sibling of Anaconda: it bundles conda, Python and a few core tools like pip, and leaves the rest up to you.

Miniconda download options
Pick the installer for your system.

Step 1.2: Open the downloaded installer. On the welcome screen, click Next >.

Miniconda installer welcome page
The installer's welcome screen.

Step 1.3: Read through the licence and click I Agree.

Miniconda license agreement
Accept the licence.

Step 1.4: When asked who the installation is for, choose Just Me (the right choice on a personal computer) and continue.

Installation type: Just Me
Install for your user account only.

Step 1.5: Choose where Miniconda should live. The suggested folder is fine as long as the drive has free space.

Choosing the installation folder
Keep the default folder unless space is tight.

Step 1.6: On the advanced options screen, tick both boxes:

  • Add Miniconda3 to my PATH — so your terminal can find Python and conda from anywhere.
  • Register Miniconda3 as my default Python — so other programs, VS Code included, pick it up automatically. Each project can still use a different Python version later.
Advanced installation options
Tick both options.

Step 1.7: Click Install and let it run. It usually takes a minute or two.

Installation in progress
Installing…

Step 1.8: Once the screen reads Installation Complete, click Next >.

Installation complete
Done.

On the last screen you can untick the two optional links to tutorials, then click Finish.

Finish page
Untick the extras and finish.

2. Install VS Code

Step 2.1: Grab the installer from the VS Code download page. The screenshots here show Windows (64-bit), but the steps on macOS and Linux are nearly identical.

VS Code download page
Download VS Code for your platform.

Step 2.2: Run the installer, accept the licence, and click Next >.

VS Code license agreement
Accept the licence.

Step 2.3: Confirm the install folder; the default is usually best.

Choosing the VS Code folder
Choose where VS Code is installed.

Step 2.4: The installer offers to add a Start Menu shortcut. Leave it as is and click Next >.

Start Menu shortcut
A Start Menu shortcut for quick access.

Step 2.5: Tick the extra options shown below. A desktop icon is handy, and adding VS Code to PATH lets you open any folder in it straight from a terminal.

Additional tasks: desktop icon and PATH
Recommended extra options.

Step 2.6: Review the summary of your choices and click Install.

Ready to install
Ready to go.
Installation in progress
Installing VS Code.

Step 2.7: When setup finishes, click Finish to open VS Code for the first time.

Setup complete
Launch VS Code.

You'll be greeted by the welcome screen:

VS Code welcome screen
VS Code on first launch.

Step 2.8: Out of the box, VS Code doesn't know much about Python. Microsoft's free Python extension fixes that, adding smart code completion (Pylance), error checking, debugging, formatting, a variable explorer and more.

  1. Open the Extensions view: the icon of four small squares in the left sidebar.
  2. Search for Python (this needs an internet connection).
  3. Pick the one published by Microsoft.
  4. Click Install.
The Python extension by Microsoft
Search for the Python extension.

Once installed, the extension page looks like this:

Python extension installed
The extension is ready.

Step 2.9: Now let's see which Python VS Code can find. Switch back to the Explorer (the top icon in the sidebar), then:

  • Press Ctrl+Shift+P to open the Command Palette — a search box for every command and setting in VS Code. You'll use it a lot.
  • Type Select Interpreter and choose Python: Select Interpreter.
Searching for Python: Select Interpreter
Find the interpreter picker.

After a moment, VS Code lists every Python it found. Right now there's just one: the base Python 3.9.7 that came with Miniconda. You could start coding with it straight away, but there's a better habit to build first.

The base interpreter, Python 3.9.7
Only the base interpreter so far.

3. Create a project environment

Step 3.1: From the Start menu, open Anaconda Prompt (miniconda3).

Finding Anaconda Prompt in the Start menu
Open Anaconda Prompt.

Notice (base) at the start of the line. That tells you which environment is currently active.

Anaconda Prompt in the base environment
You start in the base environment.

Step 3.2: Create a new environment with this command, swapping in a name of your choice. The python= part pins the Python version, which doesn't have to match base:

Terminal
conda create --name yourenvname python=3.8

For this guide, we'll call it datascience:

Terminal
conda create --name datascience python=3.8
Creating the datascience environment
Creating the “datascience” environment with Python 3.8.

Conda shows the packages it's about to install. Type y, press Enter, and give it a moment.

Packages installed with the new environment
Confirm with y.

To check it worked, list your environments:

Terminal
conda env list

You should now see two: base and datascience.

The list of environments
Two environments, side by side.

Step 3.3: Switch into the new environment:

Terminal
conda activate datascience

The prompt changes from (base) to (datascience). Anything you install now goes into this environment only.

The datascience environment activated
The new environment is active.

Step 3.4: Time to add some tools. Every package installs the same way:

Terminal
conda install library_name

First, ipykernel. It's what lets VS Code run Jupyter notebooks with this environment:

Terminal
conda install ipykernel
Installing ipykernel
Installing ipykernel.

Then the everyday data-science essentials: pandas for working with tables, and matplotlib, seaborn and plotly for charts:

Terminal
conda install pandas
conda install matplotlib
conda install seaborn
conda install plotly
Installing pandas
pandas installing.

Step 3.5: Back in VS Code, open the Command Palette (Ctrl+Shift+P) and run Select Interpreter again.

Searching for interpreters
Open the interpreter picker again.

This time the list includes your new environment. Choose Python 3.8.11 (datascience: conda) so this project uses it.

Choosing the datascience interpreter
Select the datascience environment.

4. Run your first notebook

Step 4.1: Open the Command Palette (Ctrl+Shift+P), type New Jupyter Notebook and select it. A blank notebook opens with a single empty cell.

A new, empty Jupyter notebook
A fresh notebook.

Step 4.2: Run two quick checks:

  1. Type 1 + 1 in the cell and run it, either with the ▶ button beside the cell or with Ctrl+Enter. Seeing 2 means Python is running.
  2. Add a cell below with Ctrl+Shift+B and import one of the packages you installed:
Python
import pandas as pd

No error? Then the notebook is using your datascience environment, packages and all.

Running code in the new environment
Both checks pass.

That's it — you have a clean, project-ready Python setup.

Found this useful? Pass it on to a friend or labmate who's just getting started with Python.