Why the need to use virtual environments?

KoloNuto report abuse

In articles, people often describe how to set up a virtual environment for the project but without much explanation why. So why do you need to use virtual environments, such as 'virtualenv' while working on python projects?

Answers

Tinkerberg report abuse

Hi @KoloNuto

I can think of two reasons why people use virtual environments while developing projects. There may be more.

  1. You may need different versions of the same package in different projects. If you don`t use virtual environments, you will need to manually switch versions on your machine. With virtual environments this problem is no longer existent.
  2. Usually, the development is done locally and then the finished project is deployed to server. In this case you want to be sure, that exact versions of packages are used both locally and on server and nothing is missed. When using virtual environment, there is no chance of using wrong version. Moreover, if needed, package version can be easily changed both locally and on server, without the need to manually reinstall them.
Add Answer

Need support?

Just drop us an email to ... Show more