Virtual Environment walkaround and Flask installation
Tags: python, tutorial, vscode, flask
Published: 2021-11-20 15:12:50

Imagine you live in your 1 room big house having the size of 40 feet by 50 feet. The house doesn't have any separate rooms and you live with your family. You want to make a video of yours practising playing guitar but you aren't able to follow the metronome ticks due to the distractions of the people moving in front of you.

What would be the viable solution to carry out the passion of playing guitar or recording it? 

You might move to a separate room. But to construct a separate room it would put a dent on your wallet. How about you cordon off a small area with curtains? That would be feasible as well as it would help you in cutting off the distractions and you could carry on with your passion of playing the guitar and mastering it.

Virtual environment works in the same manner like the makeshift guitar practising room. 

*You could install packages and libraries and work on your projects without impacting the global environment.*


To get started let's dive in ...


- 
**Open Terminal**


![1S.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637390376224/TeIL5futm.png)


- 
**Select the drive you want work on (Eg : I would be selecting Desktop)**


```
cd Desktop
``` 


![2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637390605735/FTe_0_PAp.png)



- 
**Create the directory (Eg : The directory created is Project)**


```
mkdir Project
``` 


![3.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637390729221/OCwtlosU1.png)


- 
**Get inside the Project folder**


```
cd Project
``` 


![5.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637419507413/15UCYMbx4I.png)



- 
**Install the Virtual environment (Eg : 'project_env' as Virtual environment)**


```
python3 -m venv Project_env
``` 



![6.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637419574825/-ZUZUhQgM.png)



- 
**List out all the files in the Project folder**


```
ls
``` 


![7.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637419682431/JRLi4m1PU.png)




- 
**List out all the packages which are installed**



```
pip freeze
``` 


- 
**Activate the virtual environment**


```
source project_env/bin/activate
``` 



![8.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637419973808/RnW5UeY6b.png)




- 
**The name of the Virtual environment comes in front after it's activation**


![9.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637420057248/IuM3cof2T.png)


- 
**Install a Python library say Flask**

```
pip install flask
``` 

![10.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637420220298/bH_YVK0NZ.png)

# After Installation


![11.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637420316360/6BIikl_Ws.png)


- 
**Verifying the proper Installation**


```
python
``` 


![12.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637420407444/6bfh4GIvb.png)



```
import flask
``` 



![13.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1637420455589/XijUIrmq0.png)

**If no errors are shown then it means that the module has been installed correctly.**



*Thanks for reading.*

Drop in your suggestions. 

*Brickbats and Bouquets are welcome.*