Quickstart/Virtual Environments

From HPC
Revision as of 09:20, 3 November 2022 by Pysdlb (talk | contribs) (Why should you use a Virtual Environment?)

Jump to: navigation , search

What is a Virtual Environment?

A virtual environment is a named, isolated, working copy of Python that maintains its own files, directories, and paths so that you can work with specific versions of libraries or Python itself without affecting other Python projects.

Why should you use a Virtual Environment?

Python has various modules and packages for different applications. During our project, it may require a third-party library, which we install. Another project also uses the same directory for retrieval and storage but doesn't require any other third-party packages.

So, the virtual environment can come into play and make a separate isolated environment for both projects, and each project can store and retrieve packages from their specific environment.

Also, let us consider another case where we are creating a Deep learning project using Tensorflow. Suppose you are working on two projects project-01 and project-02.

If project-01 uses Tensorflow-2.0 and project2 uses Tensorflow-2.6, they would be stored in the same directory with the same name, and the error may occur. Then, in such cases, virtual environments can be really helpful for you to maintain the dependencies of both the projects.

How to use a Virtual Environment

Back