How to Enable Virtual Environment In Python For Visual Studio Code

Hi, In this article  let us see how to Enable Virtual Environment. So Why Virtual Environment Why not the same Terminal? If You install a package which is needed for one project Your create a folder and install the  package which is common for whole of your computer. If you want to create another project the packages will apply to the them. And you don’t want to do something with your website. So a virtual environment keeps a package within the project so the do not clash between them so follow the steps to create One

Type the following code in your terminal

$ sudo pip install virtualenv

So this will install the package for The Virtual Environment

2. Create a Folder to keep your venv

$ mkdir Environments

Go into  the folder using

$ cd Environments

3. Now add a  venv using the following code
$ virtualenv project_1

4. Activating the venv

$ source project_1/env/bin/activate

5. Installing other packages

pip install numpy

6. Converting the package into a txt file

pip freeze --local > rts.txt

After this you will see the following

This means that your venv is running successfully if not check the steps.

Delete, Deactivate from venv

Deactivate the venv

To deactivate the venv just type

$ deactivate

which will deactivate the venv and you will see the result like this:

Delete the venv

To delete the folder in which the venv is present type:

$ rm -rf project_1

then the folder will be deleted

Happy Coding

Harshith Ashok

Design a site like this with WordPress.com
Get started