Virtual Environment is used to manage our Python projects more efficiently. Every project has a dedicated environment for better results and future updates. For example, we have a project which uses Django2.1 and another one that uses Django2.2. Now, in these types of cases, we can make use of virtual environments to both projects individually without any problem. In this tutorial, we are going to see how to work with the virtual environment. We need to install virtualenv. Run the following command to see whether virtualenv is installed on your computer or not.
If you run the above command, you will see the following(maybe different version) output.
If you didn't see the version of the virtualenv then, it's not installed on your computer. Run the following command to install it on your PC.
pip install virtualenv
Now, we are ready to create our virtual environments. Follow the below steps one by one to create a virtual environment.
Command to initialize the project with virtualenv.
If you run the above command, you will get a folder with the name you mentioned.
Command to activate the virtualenv.
Now, you are in a virtual environment. Python defaults install the latest version of it in the virtualenv.
Command to deactivate.
If you have any doubts regarding the tutorial, mention them in the comment section.