The Easiest Way to Use a Python Virtual Environment with Git

GSquared
Wealthy Bytes
Published in
2 min readJul 31, 2019

--

In this story, I will explain why a virtual environment is necessary when developing in python. I will then explain how to set up and properly use a virtual environment with source control.

What is a Virtual Environment?

Setting up a virtual environment when building a python project is an essential step in the development process. A virtual environment allows dependencies to be separated between projects. A dependency is just some sort of module that is required for your project to run properly. As the dependency modules are updated, conflicts can arise between projects if dependencies are shared and the necessary versions are not the same. A virtual environment eliminates these conflicts by allowing the dependencies to be project specific and isolated from the system.

How to Do It

The process of setting up a virtual environment should be done for every project and is quite painless.

First, create a project directory and switch into it.

mkdir test-env && cd test-env

Venv is included with Python versions 3.3 and newer and is the default way of setting up virtual environments.

--

--

GSquared
Wealthy Bytes

Building and Writing. Follow for adventures in AI and practical software development to improve your day to day life 🚀