Python Basics- create, activate, deactivate and delete python virtual environment via VS-Code (MAC)
This short introduction explores one of Python’s functionalities that allows us to work on different projects by keeping all their dependencies in one place via virtual environments
We will learn this by creating a new project folder and you can implement the same for your relevant projects.
How to create and start a virtual environment(MAC):
1. Create a new folder on your mac and open it via VS Code. 2. Once done open a new terminal on your VS Code.

3. Run the following command: python3 -m venv test_venv (here test_env is the name for our virtual environment) 4. After running it successfully, you should now see some files generated on your left in VS Code. These files should be under a new folder with the same name as your new virtual environment.

5. Congratulations you have now successfully created a new virtual environment on your VS Code.
Moving forward we will now learn to Activate the environment we just created:
To do that we will have to run the following command from the terminal and it should simply activate your virtual environment. Upon successful run you should see the following output.
source test_venv/bin/activate

The brackets at the front indicate that you are now in your newly created virtual environment. You can now use this to install your favorite packages using pip install xyz command.
The command above runs the activate file from folder test_venv/bin. You can also see this file on your VS Code under the newly created folder:

Deactivate the virtual environment:
Simply typethe following command in your VS Code terminal and that should do the trick:
Deactivate
Delete the virtual environment
Type the following command in your VS Code terminal, and that’s it! To confirm, you can check that the newly created folder on your left has also been deleted.
rm -r test_venv
Congratulations you now know how to use virtual environments in python!
I hope this guide helps someone grasp Python basics. If you find my work helpful, please consider following me, as I will be writing more articles on Data Science.
References:
Python and VS Code official documentations.






