1 00:00:03,280 --> 00:00:07,540 Hello welcome to this tutorial on what Jilin y moment 2 00:00:10,130 --> 00:00:21,180 before discussing about what an environment I would like to cover some basic topics so when you install 3 00:00:21,180 --> 00:00:30,840 Python we install the python executable files a number of standard libraries and third party packages 4 00:00:31,290 --> 00:00:42,910 in our system so a directory is created in the system with a number of sub directories and finds and 5 00:00:42,970 --> 00:00:50,110 we will talk about some of the important directories of folders that are created in the system. 6 00:00:50,200 --> 00:00:56,810 The bin directory the bin directory is intended for executable. 7 00:00:57,280 --> 00:01:08,780 So mind it is the python binary file and applications will be here next is these include directly this 8 00:01:08,780 --> 00:01:14,230 contains the C header files that compile Python packages. 9 00:01:15,220 --> 00:01:17,940 The library directory. 10 00:01:18,190 --> 00:01:27,970 This directory contains these standard libraries along with the site packages folder in the site Packages 11 00:01:27,970 --> 00:01:30,980 Folder packages get installed. 12 00:01:31,090 --> 00:01:39,430 So when we use the D package manager pip in order to install packages from pi pi. 13 00:01:39,430 --> 00:01:43,810 This is where the packages get installed. 14 00:01:44,120 --> 00:01:46,600 This site packages directory. 15 00:01:46,690 --> 00:01:49,390 Now let's consider an example. 16 00:01:49,390 --> 00:01:51,600 We are developing an application. 17 00:01:52,240 --> 00:01:59,380 Application 1 and this application requires all third party packages. 18 00:01:59,380 --> 00:02:10,480 So we have installed package B one with version 1.0 or package b 2 with version 2.0 or and then package 19 00:02:10,510 --> 00:02:15,160 B 5 with version 1.0 or no. 20 00:02:15,380 --> 00:02:27,370 We have also started developing that application simultaneously application 2 and the application to 21 00:02:27,520 --> 00:02:32,480 need the packages be three before B five. 22 00:02:32,800 --> 00:02:44,790 So as you can see application one has a dependency on the package B five with was one dot or an application 23 00:02:44,800 --> 00:02:57,930 two requires the same package be filed with the next or the latest was in Washington to dot o now in 24 00:02:57,930 --> 00:03:04,060 order to develop this application application tool you need the latest version of the package B five. 25 00:03:04,440 --> 00:03:13,250 So when you go ahead and install package 5 with this was in the latest version it will all be denied 26 00:03:13,260 --> 00:03:14,670 the older version. 27 00:03:15,450 --> 00:03:25,770 An application one has a dependency on the older wash wash in one dot all of B5 and because the package 28 00:03:26,030 --> 00:03:34,380 B 5 has been upgraded in the system application one might not work as expected. 29 00:03:35,990 --> 00:03:43,970 So how do we resolve this issue such that the development of application 1 does not affect the development 30 00:03:43,970 --> 00:03:45,510 of application 2. 31 00:03:45,700 --> 00:03:55,300 And this problem can be solved using watch environment what you learn by means isolate one applications 32 00:03:55,310 --> 00:04:05,390 environment from another and what does a virtual environment watch environment allows packages to be 33 00:04:05,390 --> 00:04:13,390 installed in an isolated location for a particular application rather than being installed globally 34 00:04:13,880 --> 00:04:21,770 or watching the environment is a self-contained directory tree that contains a python installation for 35 00:04:21,770 --> 00:04:31,400 a particular version of Python plus a number of additional packages and this is a global Python installation 36 00:04:32,150 --> 00:04:40,410 which contains the different directories such as the bin include and library directories. 37 00:04:40,670 --> 00:04:48,660 And in order to avoid affecting the global Python installation here we have created what tool environment 38 00:04:49,040 --> 00:04:59,360 we e one and each watch environment has its own Python binary and can have its own independent set of 39 00:04:59,480 --> 00:05:05,020 installed Python packages in it site packages directly. 40 00:05:05,060 --> 00:05:14,890 So when we install packages from pi by using Pip all of these packages get installed in the watchful 41 00:05:14,900 --> 00:05:15,920 environment. 42 00:05:16,040 --> 00:05:27,080 When this environment is activated though the packages be one that was in one dot or b Two was gone 43 00:05:27,150 --> 00:05:28,520 to dot or. 44 00:05:29,320 --> 00:05:36,490 And then PFI which was in one dot all can be installed in this virtual environment. 45 00:05:37,540 --> 00:05:46,540 And we can create as many virtual environment as required so for application to we are going to create 46 00:05:46,630 --> 00:05:48,340 another virtual environment. 47 00:05:50,040 --> 00:05:52,170 And we do. 48 00:05:52,770 --> 00:06:03,330 And in this world environment we are going to install the packages P3 with version 1.0 or P4 version 49 00:06:03,370 --> 00:06:11,520 2.0 or p 5 version to dot or in this virtual environment. 50 00:06:11,520 --> 00:06:12,560 We do. 51 00:06:12,810 --> 00:06:23,220 So we have created two isolated independent environments so that the applications can be developed without 52 00:06:23,280 --> 00:06:25,110 affecting each other. 53 00:06:25,110 --> 00:06:33,930 The recommended way to create a virtual environment is to use the WI and we module if you're using Python 54 00:06:33,930 --> 00:06:41,250 3 and above then you should already have the BMV module from the standard library installed. 55 00:06:42,810 --> 00:06:48,920 And this is the command to create a what will and why. 56 00:06:49,560 --> 00:06:53,790 So let's go ahead and create a what an environment in the system 57 00:06:57,070 --> 00:07:06,670 in your windows is to go to the command prompt and type the command Python hyphen M V E in the is the 58 00:07:06,670 --> 00:07:18,440 module and the part where you want to create your word you'll environment then hit enter this step will 59 00:07:18,440 --> 00:07:24,750 install Python Pip and basic libraries within the project folder. 60 00:07:24,770 --> 00:07:33,340 In our example in our case the tutorial folder so let's go to this folder. 61 00:07:33,350 --> 00:07:40,610 This is the virtual environment that has been created the target directory and it has created three 62 00:07:41,120 --> 00:07:50,660 sub directories these grip directly on the bin directory contains a copy of the Python binary so let's 63 00:07:50,660 --> 00:08:02,590 go to this directory and in the been directory you have the executable files for Pip and python. 64 00:08:02,610 --> 00:08:09,470 Now let's go back let's go to the library directory 65 00:08:12,400 --> 00:08:17,520 so the library directory contains the site packages folder. 66 00:08:17,600 --> 00:08:25,720 These site packages for low contains the packages Pip and set up tools and Pip is used to install packages 67 00:08:25,810 --> 00:08:28,510 into this site packages folder. 68 00:08:31,450 --> 00:08:36,200 And then let's go back. 69 00:08:36,320 --> 00:08:39,590 These include folded is empty. 70 00:08:40,970 --> 00:08:51,530 Apart from these three folders we also have another file deep by the end B dot c g and this is a configuration 71 00:08:51,530 --> 00:08:58,250 file and the existence of this file indicates Python that there is a virtual environment. 72 00:08:58,880 --> 00:09:02,560 So we have created a virtual environment next. 73 00:09:02,750 --> 00:09:09,850 Let's see how to activate the virtual environment and then install packages into the virtual environment.