Python coding setup windows

PYTHON Published Updated 3 mins read By Leon Wei
Python coding setup windows cover image

Quick summary

Summarize this blog with AI

A working Python setup has one selected interpreter, a project-specific environment, and an editor using that same environment. This guide follows a single Windows PowerShell path for a small pandas project. It uses explicit interpreter paths, so activation and PowerShell execution-policy changes are unnecessary.

Verification boundary: the Windows install-manager commands below were checked against Python's current official documentation, but this article was not tested on a fresh Windows machine. The Python analysis fixture was executed on macOS with Python 3.12.14 and pandas 2.2.3 and 3.0.6. Treat local path/version output as something to verify on your machine, not a fabricated Windows transcript.

Install Python through the official Windows route

Use the official Windows download page and its Python Install Manager instructions. On a managed work machine, use the approved installation route. The current manager uses py install; an older legacy py launcher may not support that command. Confirm which tool you have before mixing old launcher advice with the new manager.

This tutorial chooses Python 3.12 for its tested example environment; it is not a claim that 3.12 is the newest release. Install a supported patch through the manager and verify it:

py install 3.12
py -V:3.12 --version

The patch number depends on the available runtime. If py is missing, complete the official install-manager setup and open a new terminal. If py exists but rejects install, consult the official documentation's legacy-launcher troubleshooting. Do not download an interpreter from an arbitrary search advertisement.

Create an isolated project environment

In an existing parent folder where you have write access, choose a new project directory name. Run these PowerShell commands once for that new directory:

New-Item -ItemType Directory -Path pandas-practice
Set-Location pandas-practice
py -V:3.12 -m venv .venv
.\.venv\Scripts\python.exe -m pip install pandas==3.0.6
.\.venv\Scripts\python.exe -c "import sys, pandas; print(sys.executable); print(pandas.__version__)"
.\.venv\Scripts\python.exe -m pip check

The executable path must end in this project's .venv\Scripts\python.exe; pandas should report 3.0.6. A successful pip check reports no broken requirements. The exact folder prefix is yours. Always use the selected interpreter's -m pip so installing a package and running Python target the same environment. Pinning pandas alone does not lock every transitive dependency; capture and review a full environment lock when reproducibility requires it.

Run a complete analysis fixture

Save this as analysis.py next to the .venv folder. Use a plain text Python file, not analysis.py.txt.

import pandas as pd

sales = pd.DataFrame({"region": ["East", "West", "East"],
                      "revenue": [10, 7, 15]})
print(sales.groupby("region", sort=True)["revenue"].sum().to_dict())

Expected output:

{'East': 25, 'West': 7}
.\.venv\Scripts\python.exe analysis.py

The result above is deterministic for the supplied data. It tests import, DataFrame creation, and aggregation together. It does not require a database, remote dataset, or account. An import failure at this stage is an environment issue; inspect the interpreter path before modifying the code.

Make the editor and notebook use the same environment

Open the pandas-practice folder in your editor. In VS Code with the Python extension, run Python: Select Interpreter and select this project's .venv interpreter. Execute analysis.py from the editor, and compare its result and sys.executable with the terminal. A terminal prompt that shows an environment name does not prove every editor feature selected it.

If you need notebooks, add a kernel to this same environment:

.\.venv\Scripts\python.exe -m pip install ipykernel

Select that environment in the notebook's kernel picker. In a cell, run import sys; print(sys.executable), then the analysis fixture. The path must refer to .venv. Notebook support was documentation-reviewed here; Windows editor and kernel UI interactions were not executed.

Resolve mismatches with evidence

ProblemTargeted check
ModuleNotFoundError for pandasRun the explicit .venv interpreter's -m pip show pandas
python opens the Microsoft StoreUse the explicit .venv path and review Windows app-execution aliases in the official setup guide
Editor works but notebook failsCompare sys.executable in both contexts
Activation is blockedUse the direct interpreter commands above; activation is optional
Wrong file is executedCheck the working directory and filename extension

Do not globally relax execution policy or reinstall every Python version as a first response. A virtual environment can be recreated from declared dependencies; keep your own code and datasets outside .venv and never treat deleting the whole project as environment cleanup.

References: Python on Windows, venv, VS Code Python environments, and notebook kernel selection.

Interview Prep

Begin Your SQL, Python, and R Journey

Master 230 interview-style coding questions and build the data skills needed for analyst, scientist, and engineering roles.

Related Articles

All Articles
Python coding setup windows cover image
python Oct 17, 2026

Python coding setup windows

Master Python development on Windows with a guide to setting up your coding environment. Embrace Python's simplicity and power for diverse appli…