Create a Python Virtual Environment on Windows (py -m venv)
Isolate each project's packages in a .venv folder and activate it in PowerShell.
01Command
$ py -m venv .venv ; .venv\Scripts\Activate.ps102What it does
The venv module creates a self-contained folder with its own Python interpreter and site-packages, so pip installs stay local to the project. The py launcher picks your default Python 3 installation. Once activated, your prompt shows (.venv) and `pip install` affects only this environment; deactivate with the `deactivate` command.
03Risk
04Undo
$ Remove-Item -Recurse -Force .venv05Sources
- venv — Creation of virtual environmentsEvidence: Documents python -m venv and the Windows activation path Scripts\activate (Activate.ps1 for PowerShell).
- Python Tutorial: Virtual Environments and PackagesEvidence: Official tutorial explains creating a venv and activating it with Scripts\activate on Windows.
Last verified: 2026-09-19 · Category: Developer
06Related solutions
Use Windows Package Manager to install, search, and upgrade thousands of applications from the community repository in one command.
Understand PowerShell's execution policy scopes and set the one that lets you run your own local scripts without gutting the security model.
Search inside text files and logs with regex, returning file, line number and match.