activate and deactivate python virtualenv code example

Example 1: create a venv

# Create the virtual environment.
python -m venv venv

# Activate the env.
venv\Scripts\activate.bat

Example 2: how to deactivate virtualenv

# This would only work when you have virtualenv activated.
# Kinda obvious, but I guess I'll point it out.

# Just type in this in your shell:
deactivate

Example 3: venv python deactivate

$ deactivate

Example 4: how to activate the pytho virtual environment

mypthon\Scripts\activate