Skip to content

How to activate venv in Git Bash on Windows

When running venv/Scripts/activate doesn't appear to work.

TL;DR

. venv/Scripts/activate

Explanation

venv is a virtual environment for Python development.

Normally, on Windows, you create it with something like:

# create a new virtual named 'venv' in your current directory
python -m venv venv

And then activate it with one of:

1
2
3
4
# Powershell
venv/Scripts/activate.ps1
# Batch script
venv/Scripts/activate.bat

However, in Git Bash, running the following doesn't appear to activate the environment:

venv/Scripts/activate

According to this Stackoverflow answer, this is because running the script runs it in a new instance of the shell, which is destroyed after execution.

To activate it in your current shell:

. venv/Scripts/activate