Python Virtual Environments are Actually Easy… (If You Don’t Make Them Complicated).
How to set up a virtual environment: A super easy, lightweight solution to quickly and efficiently set up portable environments for your Python projects. Let’s begin.
What is a virtual environment for? Why do you need one? A virtual environment helps keep your project bundled together with a list of its dependencies. This makes it portable and easy for someone else to open your project and get it up and running without dozens of import errors. We’ll assume you know why you should have an environment but have you been digging around for a straightforward tutorial without all the fluff? Here it is.
Virtualenv
We’re going to use the virtualenv package becuase it is really easy.
- In terminal, navigate to your project folder. Once there, type this:
virtualenv venv
If you have Python 3.3 or greater virtualenv is included. If not, quickly google “install virtualenv <insert your OS here>” and come right back. Once you finish step one, it should have created a child folder in your project folder called venv.
2. Next, while still in the project folder, type this: