DEV Community

Devkant Swargiary
Devkant Swargiary

Posted on

Virtual Environment walkaround and Flask installation

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

  • Select the drive you want work on (Eg : I would be selecting Desktop)
cd Desktop
Enter fullscreen mode Exit fullscreen mode

2.png

  • Create the directory (Eg : The directory created is Project)
mkdir Project
Enter fullscreen mode Exit fullscreen mode

3.png

  • Get inside the Project folder
cd Project
Enter fullscreen mode Exit fullscreen mode

5.png

  • Install the Virtual environment (Eg : 'project_env' as Virtual environment)
python3 -m venv Project_env
Enter fullscreen mode Exit fullscreen mode

6.png

  • List out all the files in the Project folder
ls
Enter fullscreen mode Exit fullscreen mode

7.png

  • List out all the packages which are installed
pip freeze
Enter fullscreen mode Exit fullscreen mode
  • Activate the virtual environment
source project_env/bin/activate
Enter fullscreen mode Exit fullscreen mode

8.png

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

9.png

  • Install a Python library say Flask
pip install flask
Enter fullscreen mode Exit fullscreen mode

10.png

After Installation

11.png

  • Verifying the proper Installation
python
Enter fullscreen mode Exit fullscreen mode

12.png

import flask
Enter fullscreen mode Exit fullscreen mode

13.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.

Top comments (0)