Page 178 - AI Ver 1.0 Class 10
P. 178

What is a Virtual Environment?


              A virtual environment is an important tool that helps you create a unique isolated environment for each project
              in Python. This means each environment will have its own set of activities, software usage settings, packages
              used, including its own different Python versions. This is useful if you need different versions of Python or
              packages for different projects. For example, if a Python developer is using version 2.8 for one project and
              version 3.4 for another project then the virtual environment seems to be very useful in providing separate
              environments.


              Creating a Virtual Environment
              The steps for creating a virtual environment using Anaconda distribution are given below:

                 • Go to Start → type Anaconda Prompt in Search and click on it to open Anaconda Prompt.


































                 • This will open a window with default (base) written to show that it is the default environment in which the
                 anaconda works. We can create our own virtual environment to work in our own projects without affecting the
                 base virtual environment.
              Let us create our own virtual environment by giving the following command at the prompt sign:

              conda create -n myenvion Python=3.8.10











                 • The above code will create a new environment named myenvion with Python 3.8.10 and some basic packages
                 useful for working in it.




                        176   Touchpad Artificial Intelligence-X
   173   174   175   176   177   178   179   180   181   182   183