Why is virtual environment necessary?

Virtual environment makes it easy for you to release your project with its own dependent modules.For example, you can make it easy to create your requirements.txt file for heroku deployment.

Install a virtual environment with:

$ pip install virtualenv

Creating a virtual environment with:

$ python -m venv venv

Note: The last venv is a subdirectory.

Activate the virtual environment with:

$ source venv/Scripts/activate

To view all the installed files:

$ pip freeze

To deactivate your virtual environment:

$ deactivate

References
https://stackoverflow.com/questions/23948317/why-is-virtualenv-necessary https://docs.python.org/3/library/venv.html https://dev.to/bricourse/most-successful-developers-use-python-virtual-environments-do-you-know-how-3bh7