The Right Way to Use Virtual Environments

Separate the environment from the source code.

# Make a project folder
mkdir myproject && cd myproject
 
# Now create the virtual environment inside its own folder. Call it venv or env or something obvious:
# Python3.6; pyvenv script has been deprecated in favour of python3 -m venv
python3 -m venv venv
 
# Put the venv in your .gitignore:
git init
echo 'venv' > .gitignore
 
# This keeps your virtual environment out of source control.
# Activate the environment:
source venv/bin/activate
 
# Install something into the environment
pip install bs4
 
# Freeze the requirements:
pip freeze > requirements.txt
 
# Check requirements.txt into source control:
git add requirements.txt
 
# When deploying elsewhere, activate the environment before installing the requirements:
pip install -r requirements.txt
References
https://medium.com/@jtpaasch/the-right-way-to-use-virtual-environments-1bc255a0cba7
Fixed venv creation cmd and activation command.