Project- How to build low-latency deep-learning-based flask app

10 / 17

What is a Virtual Environment

What is a Virtual Environment?

  • As the name suggests, it is an environment virtually created to isolate the projects.

  • This isolation helps to avoid discrepancies between the different versions of the libraries or packages as used by different projects in our system.

Why do we use a Virtual Environment?

  • Say, we have installed Flask Framework of version 1.1 some time ago, and have built an app(say App A) based on that.

  • Later, if we want to build an app(say App B) with the latest version of Flask, we need to upgrade Flask.

  • Now that we have upgraded Flask on our system, we no longer will be able to run the App A smoothly, due to the differences in the versions.

  • Virtual environments come to the rescue. If we create the two apps in 2 different virtual environments and install the corresponding packages or libraries in each virtual environment, both the apps run smoothly.

  • For the above-mentioned reasons, it is a best practice to create any project in a virtual environment. We can create any number of virtual environments which is an incredible thing.

How to create and use a Virtual Environment?

  • Creating a Virtual Environment:

    • We create a virtual environment with the name we mention using the following command: virtualenv <<your virtual environment name>>.

    Ex: virtualenv my_first_venv creates a virtual environment named my_first_venv.

  • Activating a Virtual Environment:

    • After creating the virtual environment, we switch to that environment to create our project and install the dependencies inside that environment.

    • We switch to a virtual environment by using: source <<your virtual environment name>>/bin/activate

    Ex: source my_first_venv/bin/activate command switches to the virtual environment named my_first_venv.

  • Deactivating a Virtual Environment:

    • To exit the environment, we just need to use the command: deactivate

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...