Sitemap
Chandrachudsiddharth

Chandrachudsiddharth

Understanding Python Virtual Environment Activation in Windows PowerShell

4 min readAug 12, 2026

--

If you’re learning Python on Windows, you’ve probably seen commands like:

.\venv\Scripts\Activate.ps1

and:

.venv\Scripts\activate

At first glance, they look almost identical. So what is actually different?

Let’s break it down.

What Is a Virtual Environment?

A Python virtual environment is an isolated environment for your project.

For example, suppose you have two projects:

Project A → Django 5
Project B → Django 6

Installing everything globally can create dependency conflicts.

A virtual environment solves this by keeping each project’s packages separate.

You can create one using:

python -m venv venv

This creates a directory like:

venv/
├── Include/
├── Lib/
├── Scripts/
│ ├── activate
│ ├── activate.bat
│ ├── Activate.ps1
│ ├── python.exe
│ └── pip.exe
└── pyvenv.cfg

The important directory here is Scripts.

What Does Activation Actually Do?

When you activate the virtual environment, your shell’s PATH is temporarily modified so that commands such as:

python
pip

point to the Python installation inside your virtual environment.

Before activation:

python
↓
System Python

After activation:

python
↓
venv\Scripts\python.exe

That’s why your terminal usually changes to something like:

(venv) PS D:\MyProject>

The (venv) tells you that the environment is active.

Understanding .\venv\Scripts\Activate.ps1

If you’re using PowerShell, this is the clearest command:

.\venv\Scripts\Activate.ps1

Let’s break it down.

.\

The .\ means:

Look in the current directory.

For example, if you’re currently inside:

D:\Ai_Engineer\Week1\day3_practice1

then:

.\venv\Scripts\Activate.ps1

means:

D:\Ai_Engineer\Week1\day3_practice1\venv\Scripts\Activate.ps1

venv\Scripts\

This points to the scripts directory inside your virtual environment.

Activate.ps1

This is the PowerShell activation script.

The .ps1 extension means it is a PowerShell script.

Therefore:

.\venv\Scripts\Activate.ps1

essentially means:

Run the PowerShell activation script located inside my virtual environment.

What About .venv\Scripts\activate?

You may also encounter:

.venv\Scripts\activate

There are actually two things to notice here.

First, .venv and venv are different directory names.

venv/

and:

.venv/

are both common names for Python virtual environments.

If you created your environment with:

python -m venv .venv

then you should activate it using:

.\.venv\Scripts\Activate.ps1

If you created it with:

python -m venv venv

then use:

.\venv\Scripts\Activate.ps1

Why Are There Different Activation Files?

Python creates different activation scripts for different command-line environments.

Inside:

venv\Scripts\

you’ll commonly see:

activate
activate.bat
Activate.ps1

They are intended for different shells.

FileUsed withactivateBash-like shellsactivate.batWindows Command PromptActivate.ps1Windows PowerShell

Get Chandrachudsiddharth’s stories in your inbox

Join Medium for free to get updates from this writer.

So if you’re working in PowerShell, the safest and clearest choice is:

.\venv\Scripts\Activate.ps1

PowerShell vs CMD

This is an important distinction for beginners.

PowerShell

Use:

.\venv\Scripts\Activate.ps1

Command Prompt

Use:

venv\Scripts\activate.bat

Git Bash / Linux / macOS

Typically:

source venv/bin/activate

The activation command depends on the shell you’re using.

Why Does .\ Matter in PowerShell?

PowerShell treats commands differently from CMD.

For example, suppose you have:

hello.ps1

in your current directory.

You generally execute it explicitly with:

.\hello.ps1

The .\ tells PowerShell:

Execute the file from the current directory.

This is why you’ll frequently see:

.\venv\Scripts\Activate.ps1

instead of simply:

venv\Scripts\Activate.ps1

What If PowerShell Says Scripts Are Disabled?

You may encounter an error similar to:

cannot be loaded because running scripts is disabled on this system

This happens because of PowerShell’s execution policy.

You can check the current policy with:

Get-ExecutionPolicy

For a development machine, a common approach is to allow locally created scripts for your user account:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Then activate the environment again:

.\venv\Scripts\Activate.ps1

Be careful when changing execution policies — understand what the policy does rather than blindly copying commands from the internet.

How Do You Know the Environment Is Activated?

After running:

.\venv\Scripts\Activate.ps1

your terminal should look something like:

(venv) PS D:\Ai_Engineer\Week1\day3_practice1>

You can also verify which Python executable is being used:

where.exe python

You should see the virtual environment’s Python executable near the top, for example:

D:\Ai_Engineer\Week1\day3_practice1\venv\Scripts\python.exe

You can also run:

python --version

and:

pip --version

venv vs .venv

You might wonder why developers use both names.

Both are valid:

python -m venv venv

or:

python -m venv .venv

The .venv convention is especially common in modern Python projects because the leading dot makes it a hidden directory on some operating systems.

For example:

my-project/
├── .venv/
├── src/
├── requirements.txt
└── README.md

A lot of modern editors and Python tooling also recognize .venv automatically.

The Most Important Thing to Remember

Don’t memorize the command blindly. Understand the pattern.

If your virtual environment is called venv:

.\venv\Scripts\Activate.ps1

If it’s called .venv:

.\.venv\Scripts\Activate.ps1

And if you’re using PowerShell, Activate.ps1 is the PowerShell-specific activation script.

Quick Cheat Sheet

Virtual environment:
python -m venv venv
PowerShell:
.\venv\Scripts\Activate.ps1
CMD:
venv\Scripts\activate.bat
Git Bash:
source venv/Scripts/activate
Deactivate:
deactivate

For a project using .venv:

python -m venv .venv
.\.venv\Scripts\Activate.ps1

Then:

pip install <package>

The package will be installed into your project’s virtual environment rather than your global Python environment.

Final Takeaway

The biggest confusion isn’t really about activate versus Activate.ps1. The important concepts are:

1. venv and .venv are directory names.

2. Activate.ps1 is the PowerShell activation script.

3. .\ tells PowerShell to execute something from the current directory.

So, when you’re working in Windows PowerShell, a good command to remember is:

.\venv\Scripts\Activate.ps1

Once you understand what each part means, Python virtual environments become much less confusing — and you’ll start recognizing the same pattern across almost every Python project you work on.

--

--