If you have just started learning python, then you may have come across the term “virtual environment”.
So whenever you are working on a project, you may need to install various dependencies of the project in the system.
There may exist a case where you need to have a different version of a library for some project A and some other version of that library for project B, so if you are not using a separate environment for both the project you may need to manually install and then uninstall the required the version of the library every time you need to run the program.
So to not mess things up, we create a virtual environment for each project.
What’s exactly is a Virtual Environment?
It is used to create and manage an isolated environment for each of your python projects.
How to create one and use?
Suppose you are going to create a really awesome project in python3.
we are using venv,
python3 -m venv env_name
activate your virtual environment
Now you can install all your project dependency in this environment using pip. Suppose you want to install numpy.
pip install numpy
deactivate the environment
I mostly use conda for creating and managing virtual environment for my data science projects.
here’s how you can use it too,
Install conda from here:
conda create -n env_name python=3.8
conda activate env_name
Hope you find this article informative,