1 00:00:00,660 --> 00:00:06,420 Hello, friends, in this video, we shall see how to set up the environment that is required for the 2 00:00:06,420 --> 00:00:09,750 development of an application using the flight framework. 3 00:00:10,050 --> 00:00:12,390 So setting the environment. 4 00:00:15,760 --> 00:00:20,080 There are certain prerequisites for setting up the environment. 5 00:00:20,500 --> 00:00:31,000 One is that you should have a Python version, two one six are, you know, even if the flask environment 6 00:00:31,000 --> 00:00:40,900 or flask package as such works for Python three point three onwards, even if it doesn't work properly, 7 00:00:41,260 --> 00:00:47,200 some of the extensions that you may want to use along with the flask, they are not properly ported 8 00:00:47,650 --> 00:00:51,820 for the next or the later versions of Python. 9 00:00:52,090 --> 00:01:00,520 So therefore it is always recommended that you should use or you should install the flat framework on 10 00:01:00,520 --> 00:01:02,220 the top of Python two point seven. 11 00:01:02,890 --> 00:01:06,760 So that is the recommended version of Python that you should use for. 12 00:01:12,290 --> 00:01:20,840 Now, in order to, you know, develop flask application, again, another recommendation is that you 13 00:01:20,840 --> 00:01:23,660 should install a virtual environment of Python. 14 00:01:24,290 --> 00:01:27,050 So this is something which is very special to Python. 15 00:01:28,100 --> 00:01:40,160 The use of virtual environment allows you to test your environment or your application in isolated environment 16 00:01:40,610 --> 00:01:47,340 so that there might be a certain case where different libraries may be conflicting with each other. 17 00:01:47,720 --> 00:01:55,650 So in order to remove the possibility of this conflict, it is always better to install a virtual environment. 18 00:01:56,810 --> 00:02:06,480 So this virtual environment can allow you to compare and test the environment side by side. 19 00:02:08,060 --> 00:02:12,890 Well, how to install that by using a utility called Pip? 20 00:02:13,810 --> 00:02:16,130 Now, Pip is a python. 21 00:02:17,670 --> 00:02:25,560 Package installer, Stolen Bank, which stands for Biton Package in stolen, not this paper utility 22 00:02:26,670 --> 00:02:36,300 for the Python two point seven point nine onwards people utility is, you know, Shipherd along with 23 00:02:36,300 --> 00:02:38,340 their standard Python distribution. 24 00:02:40,340 --> 00:02:49,670 But if you are having two point seven point eight or less than that Biton version two one seven point 25 00:02:49,670 --> 00:02:58,060 eight or less than that, then the utility is not present in the default installation of Python. 26 00:02:58,370 --> 00:02:59,630 So naturally, what will I do? 27 00:02:59,840 --> 00:03:01,940 You'll have to install the itself first. 28 00:03:03,340 --> 00:03:08,170 How to install pipe, get hold of a file called as get 29 00:03:10,430 --> 00:03:24,220 dogpile from the Python package index by B.I and then run this by saying Python get dorper. 30 00:03:25,120 --> 00:03:26,850 So what will happen now? 31 00:03:26,860 --> 00:03:33,930 The BP utility will be installed in the scripts directly off your Python Python folder wanted to install. 32 00:03:34,270 --> 00:03:42,190 Then you can, you know, run this command from the command, from PIP, install virtual EMV. 33 00:03:43,770 --> 00:03:45,730 So the virtual environment will be set up. 34 00:03:47,350 --> 00:03:53,350 Of course, this come on, nurse, an administrator privilege, especially if you are trying to do this 35 00:03:53,350 --> 00:04:02,860 under Linux or Mac OS, so if you are doing it on Linux or Mac OS, you will have to add Suto before 36 00:04:02,860 --> 00:04:07,870 it sudo pip install virtual EMV. 37 00:04:07,870 --> 00:04:11,620 That will be the command that you will use on certain. 38 00:04:12,100 --> 00:04:17,680 If you are on windows, then you have to log in as an administrator to execute that certain standard 39 00:04:17,680 --> 00:04:23,740 Linux package like you want to have their own package manager, like for example, app. 40 00:04:24,490 --> 00:04:31,810 So if you are on Ubuntu Linux, you just issuing commands to do Atget install virtual EMV so the virtual 41 00:04:31,810 --> 00:04:33,320 environment will be set up. 42 00:04:33,820 --> 00:04:40,620 Now this virtual environment will will be used to install or create an environment for the developer, 43 00:04:40,750 --> 00:04:42,220 for the installation of the flask. 44 00:04:46,950 --> 00:04:52,820 So once the virtual environment is installed now inside that virtual environment, you will install. 45 00:04:54,150 --> 00:05:03,030 So in order to install or create a new virtual environment, all you have to do is to create a new directly 46 00:05:03,390 --> 00:05:04,170 or folder. 47 00:05:04,440 --> 00:05:05,970 I'm calling it a new project. 48 00:05:05,980 --> 00:05:08,980 New project good. 49 00:05:09,030 --> 00:05:10,330 Or log in to that directive. 50 00:05:10,350 --> 00:05:15,230 I think Cindy and this virtual EMV is not already installed. 51 00:05:15,480 --> 00:05:20,730 So just the virtual EMV V and the V is the name of my virtual involvement. 52 00:05:21,390 --> 00:05:22,050 So what will happen? 53 00:05:22,650 --> 00:05:27,630 The inside of the DMV directly inside a new project, new project. 54 00:05:27,930 --> 00:05:37,110 All the required utilities and modules for a independent Pythonic distribution by Clapperton installation 55 00:05:37,110 --> 00:05:40,210 will be created inside this V v in V folder. 56 00:05:41,490 --> 00:05:44,580 So now that it is that it is there, it is done. 57 00:05:44,790 --> 00:05:53,010 The virtual environment and the utility is required for the execution of Python are installed. 58 00:05:53,850 --> 00:05:55,380 Now you can activate that. 59 00:05:55,380 --> 00:06:02,910 You will activate that environment by saying the NIBIN activate this command is especially relevant 60 00:06:02,910 --> 00:06:04,190 to the Linux distribution. 61 00:06:05,220 --> 00:06:10,290 So if you are on Linux, you said just that we and we will activate the 62 00:06:13,170 --> 00:06:15,990 newly created virtual environment will be activated. 63 00:06:19,010 --> 00:06:20,090 If you are on Windows. 64 00:06:22,300 --> 00:06:28,870 And if you are creating a virtual environment in the direction of a new project this weekend, we do 65 00:06:28,880 --> 00:06:31,220 the 3D created inside new project. 66 00:06:31,420 --> 00:06:32,170 There is a script. 67 00:06:32,170 --> 00:06:34,490 SolarReserve that and then there is an activity. 68 00:06:34,840 --> 00:06:36,070 So this is a document. 69 00:06:38,490 --> 00:06:40,660 Yankees, come on, it will be accurate. 70 00:06:40,780 --> 00:06:42,090 You know you are. 71 00:06:43,670 --> 00:06:50,010 You have installed a virtual environment, you have activated it now inside that virtual environment 72 00:06:50,040 --> 00:06:58,260 just to install flasks so the flask will be installed in the our current version in order. 73 00:06:58,560 --> 00:07:04,750 So this is all the activity that you need to do in order to set up the flask and warm it in your computer. 74 00:07:05,010 --> 00:07:11,700 Now, all these activities I will actually demonstrate to you with the help of the activities that I 75 00:07:11,700 --> 00:07:20,430 will do in front of you the recommended version of Python for installation of Lasky's Python two point 76 00:07:20,430 --> 00:07:20,820 seven. 77 00:07:21,930 --> 00:07:28,200 So in front of you, I have opened the idle shell of Python two point seven point one two. 78 00:07:28,680 --> 00:07:29,640 And this is the. 79 00:07:30,950 --> 00:07:32,800 Python thrown in front of me. 80 00:07:32,880 --> 00:07:35,000 If I write any valeted. 81 00:07:36,390 --> 00:07:38,550 Biton statement that will be. 82 00:07:40,560 --> 00:07:41,730 Properly executed. 83 00:07:41,790 --> 00:07:42,690 Which means that. 84 00:07:43,630 --> 00:07:47,230 In this machine, batons two one zero point one two is available. 85 00:07:49,360 --> 00:07:56,580 You can also verify this by executing the python interpreter from the command line. 86 00:08:00,000 --> 00:08:07,020 So in this machine, the bottom 270 kolon slashed by Tonto's to seven is the installation, the reward, 87 00:08:07,290 --> 00:08:08,400 one to seven. 88 00:08:09,120 --> 00:08:17,870 So from this command prompt, I will start the Python interpreter just by issuing Python Command. 89 00:08:18,030 --> 00:08:21,570 You see that the python prompt appears here. 90 00:08:21,570 --> 00:08:23,880 Also, I can execute any. 91 00:08:25,170 --> 00:08:25,430 In. 92 00:08:26,790 --> 00:08:28,410 Wildhorn statement like this. 93 00:08:30,360 --> 00:08:34,400 So which means that I don't have a label in this machine. 94 00:08:40,400 --> 00:08:44,990 Next is for the installation of different packages. 95 00:08:46,170 --> 00:08:49,980 Despite our distribution, must help keep utility available. 96 00:08:51,850 --> 00:09:00,640 For the pattern distributions after Python two point seven point nine BP utilities already present in 97 00:09:00,640 --> 00:09:05,910 the Python bundle, so just verify whether this is available or not. 98 00:09:05,920 --> 00:09:11,910 Otherwise, you may have to install the capability by using the get Pip Courtney while. 99 00:09:12,930 --> 00:09:19,170 How to find out whether it is present or not, just issue a simple task to search. 100 00:09:20,540 --> 00:09:22,010 All the occurrences of. 101 00:09:24,980 --> 00:09:29,570 By saying, yes, so if I see. 102 00:09:31,380 --> 00:09:38,640 This Nordyke is available in the scripts subdirectory of Bitauto seven, so it is present. 103 00:09:40,010 --> 00:09:41,270 Now that it is present. 104 00:09:42,220 --> 00:09:48,070 I have to see whether the virtual environment is present or not, so. 105 00:09:49,260 --> 00:09:50,280 If I try to. 106 00:09:51,340 --> 00:09:53,170 Install it by using the pipe. 107 00:09:53,200 --> 00:09:54,340 What happens, let us see. 108 00:09:55,820 --> 00:09:56,540 If I say. 109 00:09:58,250 --> 00:10:04,690 Scripts, because there is a folder in which the people, utilities present people. 110 00:10:05,610 --> 00:10:06,420 Install. 111 00:10:08,330 --> 00:10:10,450 Virtual envy. 112 00:10:12,470 --> 00:10:13,160 What happens? 113 00:10:17,390 --> 00:10:19,220 The requirements are already satisfied. 114 00:10:19,250 --> 00:10:23,090 That means the virtual environment is already set up in this. 115 00:10:25,610 --> 00:10:30,590 You can also verify the presence of virtual environment by running the same search command. 116 00:10:40,350 --> 00:10:49,080 There is inside the scripts, the virtual envelope is already present, so that. 117 00:10:50,400 --> 00:10:54,960 Prerequisite, prerequisite or requirement is already fulfilled. 118 00:10:58,030 --> 00:11:04,870 Now we shall use this virtual inverarity to create a virtual environment for that. 119 00:11:06,230 --> 00:11:08,170 Let me create a new folder. 120 00:11:10,340 --> 00:11:11,540 I will call it as. 121 00:11:16,520 --> 00:11:17,920 Flask envy. 122 00:11:23,160 --> 00:11:25,440 Let us log into that directly. 123 00:11:30,340 --> 00:11:37,240 And now uses virtual Ironweed or Yuxi to set up a virtual environment. 124 00:11:37,990 --> 00:11:40,180 So where is that virtual environment? 125 00:11:40,330 --> 00:11:41,490 Virtual N.V.? 126 00:11:41,890 --> 00:11:42,910 It is inside. 127 00:11:47,200 --> 00:11:48,730 This directly. 128 00:11:51,750 --> 00:11:52,740 We are. 129 00:11:58,290 --> 00:12:03,430 And then you the name of the virtual reality or virtual environment that you want to set up. 130 00:12:03,450 --> 00:12:04,950 I use the same name. 131 00:12:15,090 --> 00:12:18,500 So the virtual environment will now be set up. 132 00:12:22,990 --> 00:12:30,790 It is collecting the requirements set up to speed, will, etc., and those will be set up inside the 133 00:12:30,790 --> 00:12:32,950 flat invigilator inside the. 134 00:12:33,870 --> 00:12:40,730 Flaws in that we already created, so a folder of this name will be created and inside which all the 135 00:12:40,800 --> 00:12:41,790 quadroons will be. 136 00:12:43,130 --> 00:12:46,370 You know, installed so this the installation is complete. 137 00:12:50,550 --> 00:12:58,920 So now that the virtual environment named as class envy is set up, let us go into that directly and 138 00:12:58,920 --> 00:13:04,580 see what all the resources have been installed inside that folder. 139 00:13:07,260 --> 00:13:12,950 So this is the pattern for the way in which the virtual environment is set up by the same name Laskey, 140 00:13:13,020 --> 00:13:18,060 and this is the virtual reality folder if you expand this. 141 00:13:19,030 --> 00:13:27,520 You will find that this all include directly, live directly and scripts directly is these folders are 142 00:13:27,520 --> 00:13:29,650 created to go inside the scripts. 143 00:13:31,070 --> 00:13:31,790 This is the. 144 00:13:32,960 --> 00:13:41,270 All utilities that are required are, you know, available in this is an activity in a batch file that 145 00:13:41,270 --> 00:13:47,960 is a deactivated batch file and then there is also a local paper also is present if you want to install 146 00:13:48,260 --> 00:13:48,680 some. 147 00:13:50,510 --> 00:13:55,790 In packages inside this virtual environment, you can use these people, not you, you do not have to 148 00:13:55,790 --> 00:14:03,710 use the global pipe that is available in Python to seven additional directly in order to install something 149 00:14:03,710 --> 00:14:05,610 in this virtual environment to use these people. 150 00:14:05,900 --> 00:14:12,020 And then there is also a python interpreter which is available for the local environment or virtual 151 00:14:12,020 --> 00:14:12,510 environment. 152 00:14:12,890 --> 00:14:23,810 So this is all about the installation of virtual environment, which is the first part of our installation 153 00:14:23,810 --> 00:14:25,310 procedure in the next part. 154 00:14:26,330 --> 00:14:35,090 We shall see how to activate this virtual environment and install the package inside that. 155 00:14:37,010 --> 00:14:38,990 So this is the folder in which the. 156 00:14:40,000 --> 00:14:41,890 Virtual environment has been set up. 157 00:14:45,210 --> 00:14:49,270 This is the name of the virtual environment directly Flask N.V.. 158 00:14:53,360 --> 00:15:00,270 Inside, which there is a scripts folder and inside service that is in activate, not bad. 159 00:15:00,710 --> 00:15:01,550 So if I say. 160 00:15:04,170 --> 00:15:05,550 Go into this. 161 00:15:06,860 --> 00:15:09,560 There is a script folder. 162 00:15:14,090 --> 00:15:14,960 And there is a. 163 00:15:16,740 --> 00:15:22,680 This activity not bad, so I have to invoke this to activate the. 164 00:15:24,570 --> 00:15:25,050 This. 165 00:15:26,150 --> 00:15:32,390 Virtual environment named as Laskey in Israel go back to the parent Folden. 166 00:15:34,560 --> 00:15:36,600 And then say flask. 167 00:15:39,040 --> 00:15:40,870 Lask N.V.. 168 00:15:42,560 --> 00:15:43,520 Scripts. 169 00:15:45,730 --> 00:15:47,020 And then stick to it. 170 00:15:49,970 --> 00:15:50,300 The. 171 00:15:53,390 --> 00:15:54,050 Bagis. 172 00:15:55,450 --> 00:16:03,760 So you can find that just before the command prompt, the name of the virtual environment is appearing 173 00:16:03,760 --> 00:16:04,600 in the brackets. 174 00:16:05,530 --> 00:16:11,240 So now we are in the virtual environment from which you can invoke the python interpreter. 175 00:16:11,260 --> 00:16:15,410 Also, if you find that in the scripts folder, there is a python or the. 176 00:16:16,420 --> 00:16:21,060 So if I start this python, python will start in the virtual environment. 177 00:16:27,460 --> 00:16:28,150 Like this. 178 00:16:29,660 --> 00:16:35,910 So this is Python interpreter is now working in the virtual environment called this flask EMV. 179 00:16:36,950 --> 00:16:37,850 Come out of this. 180 00:16:40,730 --> 00:16:44,300 And come out of the virtual environment by calling. 181 00:16:45,940 --> 00:16:46,750 Deactivate. 182 00:16:51,480 --> 00:16:53,100 So we'll come back to the problem. 183 00:16:53,550 --> 00:16:54,420 So this is how. 184 00:16:55,740 --> 00:17:02,780 The second part of the virtual environment installation, how to activate, how to start python interpreter 185 00:17:02,780 --> 00:17:05,090 in the virtual environment and how to deactivate. 186 00:17:05,090 --> 00:17:07,250 That is Alwiya C. 187 00:17:09,670 --> 00:17:12,010 Then we come to the installation of Lask. 188 00:17:13,790 --> 00:17:15,020 So first. 189 00:17:17,180 --> 00:17:19,780 Activate the virtual environment. 190 00:17:25,020 --> 00:17:26,430 By calling the to. 191 00:17:28,260 --> 00:17:28,920 Batch file. 192 00:17:31,770 --> 00:17:33,390 And then run the. 193 00:17:35,610 --> 00:17:37,470 BP utility to install flask. 194 00:17:41,540 --> 00:17:43,810 It is present in the scripts folder. 195 00:17:46,440 --> 00:17:48,720 People install flask. 196 00:17:58,170 --> 00:18:05,400 All the dependencies and the modules inside the flask package will now be installed. 197 00:18:11,100 --> 00:18:16,230 Lastly, to sing successfully installed all the dependencies. 198 00:18:17,470 --> 00:18:29,410 Ginge and Works, Zogu, etc., are all installed successfully inside the virtual environment, so the 199 00:18:29,410 --> 00:18:30,520 installation is complete. 200 00:18:30,550 --> 00:18:34,570 I will now invoke the python prompt. 201 00:18:36,000 --> 00:18:39,870 And then I will say, sorry, import. 202 00:18:41,900 --> 00:18:43,170 Import flask. 203 00:18:45,410 --> 00:18:54,020 So now the flask is already present in our virtual environment, now that the flask is imported, we 204 00:18:54,020 --> 00:19:00,290 can now go ahead and use the flask framework for other activities.