1 00:00:00,000 --> 00:00:02,500 [no audio] 2 00:00:02,510 --> 00:00:03,500 Hi friends, here 3 00:00:03,500 --> 00:00:08,199 we are going to see how to install Python on your Linux or 4 00:00:08,199 --> 00:00:13,800 any Unix-like systems or 'Installing required Python on Linux'. 5 00:00:14,600 --> 00:00:19,300 See why I am saying, 'Installing required Python on Linux', because 6 00:00:20,000 --> 00:00:23,800 if we go with any one of the Unix-like systems, most 7 00:00:23,800 --> 00:00:27,300 of the Unix-like systems are already configured with anyone 8 00:00:27,300 --> 00:00:30,500 of the Python version based on the release of your Linux 9 00:00:30,500 --> 00:00:33,700 kernel. Right. Now let me open 10 00:00:35,000 --> 00:00:37,900 my OS. So this is Linux, 11 00:00:39,100 --> 00:00:40,900 or more specifically it is 12 00:00:42,100 --> 00:00:43,200 Amazon Linux, 13 00:00:43,900 --> 00:00:46,300 okay, and it is released in 2018, March. 14 00:00:47,100 --> 00:00:52,700 Now if I run simply see 'python --version' you're getting 15 00:00:52,700 --> 00:00:56,200 some Python 2.7.16, means this is the default version 16 00:00:56,200 --> 00:00:58,000 for this Linux. 17 00:00:59,400 --> 00:01:00,700 And you can also have your 18 00:01:00,700 --> 00:01:04,000 [no audio] 19 00:01:04,000 --> 00:01:05,300 'pip --version' as well. 20 00:01:05,300 --> 00:01:07,000 I mean 'pip' is also configured. 21 00:01:07,099 --> 00:01:10,400 So by default most of the Unix-like systems are configured 22 00:01:10,400 --> 00:01:15,500 with your Python, and you may get, that version maybe 2.5 or 23 00:01:15,500 --> 00:01:20,000 2.7 or 2.6, whatever it maybe based on when it was released, 24 00:01:20,600 --> 00:01:27,500 I mean your Linux, when it was released, and but here I need 25 00:01:27,500 --> 00:01:28,800 some 3.x version. 26 00:01:29,700 --> 00:01:31,500 Suppose, let us say 3.7.0 27 00:01:31,500 --> 00:01:33,500 I need on this host, 28 00:01:34,600 --> 00:01:35,700 on your Linux, 29 00:01:36,800 --> 00:01:40,000 so guys first of all before going to install your required 30 00:01:40,000 --> 00:01:45,200 Python version on your any Unix-like systems don't disturb 31 00:01:45,300 --> 00:01:50,200 existing Python because your 'm' command will depend on your 32 00:01:50,200 --> 00:01:53,800 Python, or some operations on your Unix-like 33 00:01:53,800 --> 00:01:55,600 systems will depend on your Python 34 00:01:55,700 --> 00:01:58,800 that's why don't disturb the existing Python version. 35 00:01:58,800 --> 00:02:00,500 [no audio] 36 00:02:00,500 --> 00:02:03,400 I mean whenever if you're going to install any new Python 37 00:02:03,600 --> 00:02:06,000 don't take name as 'python'. Instead of that 'python', 38 00:02:06,500 --> 00:02:09,699 let's say 'pythonx', 'pythony', something like that, or 'python3', 39 00:02:09,699 --> 00:02:12,300 in that way just take the name for your Python software, 40 00:02:13,900 --> 00:02:17,600 right? So in that way you have to install. And first let me 41 00:02:17,600 --> 00:02:21,100 enter into root. Because I have to install this python so 42 00:02:21,100 --> 00:02:25,200 I should be the root user, or you can also run from any user, 43 00:02:26,500 --> 00:02:28,300 for that you should have some root privileges. 44 00:02:28,500 --> 00:02:32,200 So instead of all confusions first I enter into root, now 45 00:02:32,200 --> 00:02:33,200 I am the root user. 46 00:02:34,200 --> 00:02:36,000 Right. Now you have some steps guys, 47 00:02:36,000 --> 00:02:37,000 very simple steps. 48 00:02:37,300 --> 00:02:38,700 Let me go with very first step. 49 00:02:39,700 --> 00:02:44,200 See let me open your official website 'python.org'. 50 00:02:44,200 --> 00:02:47,200 [no audio] 51 00:02:47,200 --> 00:02:50,000 So, you know by default you have some 'Download' tab, then 52 00:02:50,000 --> 00:02:54,100 there you can see 'View the full list of downloads', and here you 53 00:02:54,100 --> 00:02:56,200 can select your required operating system. 54 00:02:56,200 --> 00:02:59,300 I'm going to work with Unix-like systems, then simply 55 00:02:59,300 --> 00:03:02,100 I'm clicking on 'Linux/Unix'. 56 00:03:03,200 --> 00:03:07,500 Now see you have latest releases, but I need suppose 3.7.0, 57 00:03:07,500 --> 00:03:11,100 let me go and see somewhere my 3.7.0. Here 58 00:03:11,100 --> 00:03:13,200 I'm having my 3.7.0. 59 00:03:14,400 --> 00:03:17,400 Right. So let me download your 'source tarball'. 60 00:03:18,100 --> 00:03:21,300 So to download that on your Unix-like systems, from command 61 00:03:21,300 --> 00:03:22,500 line of your Unix-like systems 62 00:03:22,500 --> 00:03:26,200 you can download. So for that just copy the link location 63 00:03:26,200 --> 00:03:27,900 of your required Python software. 64 00:03:27,900 --> 00:03:30,100 [no audio] 65 00:03:30,100 --> 00:03:35,700 I copied the link location. Now go to here and first check 66 00:03:35,800 --> 00:03:39,500 whether 'wget' command is there or not. If it is not there 67 00:03:39,900 --> 00:03:42,900 just simply run 'sudo yum install wget'. 68 00:03:44,500 --> 00:03:47,400 Right. Already there, that's why it is not installing. 69 00:03:48,600 --> 00:03:51,000 Then let me enter into any location. 70 00:03:51,100 --> 00:03:52,700 So I'm entering into '/opt/'. 71 00:03:53,400 --> 00:03:57,900 So there I am going to download my Python software, Python 72 00:03:57,900 --> 00:04:01,700 'tar source wall, right. After that 73 00:04:02,700 --> 00:04:04,800 now see that. Just now you downloaded 74 00:04:04,800 --> 00:04:07,300 your required Python package. 75 00:04:08,100 --> 00:04:09,800 Now, you have to extract it. 76 00:04:09,800 --> 00:04:11,600 [no audio] 77 00:04:11,600 --> 00:04:18,899 Right. So to extract that simply use 'tar -xvzf'. So here 78 00:04:18,899 --> 00:04:21,700 'v' for 'verbose'. You can see the information while extracting. 79 00:04:22,899 --> 00:04:23,899 That's it. 80 00:04:25,200 --> 00:04:28,700 Right. Now you have your extracted package. 81 00:04:29,200 --> 00:04:32,000 Now you can go and install your Python, but before going 82 00:04:32,000 --> 00:04:35,300 to install your Python, right, actually this is a source file, 83 00:04:35,600 --> 00:04:38,900 you need to compile. To compile that you need some compiler 84 00:04:39,400 --> 00:04:41,000 and some packages as well. 85 00:04:41,000 --> 00:04:44,200 I mean some dependencies you need to install your 86 00:04:44,200 --> 00:04:45,400 Python on your host. 87 00:04:45,900 --> 00:04:50,100 So I have a list of dependencies, right, just before going 88 00:04:50,100 --> 00:04:51,200 to install your Python 89 00:04:51,400 --> 00:04:54,900 just run this command 'yym install', your 'gcc 90 00:04:55,100 --> 00:04:58,700 openssl - devel', right, all those things you have to install. 91 00:04:58,700 --> 00:05:03,500 [no audio] 92 00:05:03,500 --> 00:05:08,800 Once if we install all these dependencies, all these packages, 93 00:05:08,900 --> 00:05:13,300 right, now just navigate into your extracted directory, or 94 00:05:13,300 --> 00:05:18,300 extracted Python package, and there if you observe you have 95 00:05:18,300 --> 00:05:23,900 some 'configure', now run './configure' command first. 96 00:05:25,300 --> 00:05:29,400 So here guys, basically your './configure' you are going 97 00:05:29,400 --> 00:05:32,800 to provide to check your configuration details along with 98 00:05:32,800 --> 00:05:35,500 that you can also provide the path where you want to install 99 00:05:35,500 --> 00:05:40,300 your Python, with this option '--prefix'. Then suppose 100 00:05:40,300 --> 00:05:41,900 I want to install somewhere '/usr' 101 00:05:43,500 --> 00:05:48,800 some '/bin' location, yes you can provide your path, or if you 102 00:05:49,200 --> 00:05:54,500 skip this value, '--prefix' value, by default your 'configure' 103 00:05:54,500 --> 00:06:01,300 will install, right, your Python package, required Python under 104 00:06:01,300 --> 00:06:03,600 '/usr/local/bin'. In this location by default 105 00:06:03,600 --> 00:06:06,200 it will install. So I want to install in that location only, 106 00:06:06,200 --> 00:06:10,100 that's why I'm not giving any prefix, right. And you can also 107 00:06:10,100 --> 00:06:14,800 use some '--enable-optimizations', right, if you provide this 108 00:06:14,800 --> 00:06:17,700 option it will take some time so you can check it by providing 109 00:06:17,700 --> 00:06:21,700 '--enable-optimizations'. But I am not giving that because 110 00:06:22,200 --> 00:06:23,900 it will take some time, right. 111 00:06:23,900 --> 00:06:27,200 You can just try, or you can also try simply './configure', 112 00:06:28,000 --> 00:06:29,000 just 'Enter'. 113 00:06:29,000 --> 00:06:34,100 [no audio] 114 00:06:34,100 --> 00:06:38,100 So it will take some time to configure your details on your host. 115 00:06:38,100 --> 00:06:40,000 [no audio] 116 00:06:40,000 --> 00:06:43,300 So after configuration, simply you have to compile your 117 00:06:43,300 --> 00:06:46,800 code, I mean your, whatever the package you download it, 118 00:06:46,800 --> 00:06:48,400 right, that you have to compile. 119 00:06:48,400 --> 00:06:51,900 So for that you need to run a command called 'make', so that 120 00:06:51,900 --> 00:06:53,900 you are going to compile your code. 121 00:06:53,900 --> 00:06:55,700 [no audio] 122 00:06:55,700 --> 00:06:57,500 Right. Yes, done. 123 00:06:57,500 --> 00:07:01,100 Now, let me run 'make', and before that observe that it is also giving 124 00:07:01,100 --> 00:07:04,400 a suggestion called 'Please run ./configure -- 125 00:07:04,400 --> 00:07:08,300 enable-optimizations', right to give this information. 126 00:07:08,900 --> 00:07:12,200 But anyway I'm not running that, you can try it, right. Now 127 00:07:12,200 --> 00:07:13,300 after configuration 128 00:07:13,300 --> 00:07:16,500 just run 'make'. So 'make' is nothing but you are going to compile 129 00:07:16,500 --> 00:07:21,400 your downloaded, your Python source code. Once if we compile 130 00:07:21,400 --> 00:07:23,600 then you can install, right. 131 00:07:23,600 --> 00:07:24,700 So now I am compiling. 132 00:07:25,700 --> 00:07:27,000 So it will take some time. Again, 133 00:07:27,300 --> 00:07:28,500 just wait for some time. 134 00:07:28,800 --> 00:07:30,800 So once it is done then we'll go and install. 135 00:07:30,800 --> 00:07:59,100 [no audio] 136 00:07:59,100 --> 00:08:04,100 So still it is compiling your Python package. 137 00:08:07,300 --> 00:08:09,600 Yes, your compilation is done. 138 00:08:09,700 --> 00:08:11,700 Now simply run 'make'. 139 00:08:11,700 --> 00:08:14,100 [no audio] 140 00:08:14,100 --> 00:08:16,700 So guys in case if we have, if we don't 141 00:08:16,700 --> 00:08:19,200 have any previously installed Python versions, then simply 142 00:08:19,200 --> 00:08:22,500 you can run 'make install', but we already have Python version, 143 00:08:22,600 --> 00:08:24,900 and you don't want to disturb that that's why use 144 00:08:24,900 --> 00:08:28,500 'make altinstall', and 'Enter'. 145 00:08:29,700 --> 00:08:32,500 Now it is going to install your Python. 146 00:08:33,500 --> 00:08:35,900 Right. Again, it will take some time. Just wait. 147 00:08:36,500 --> 00:08:38,299 So once it is done then 148 00:08:39,299 --> 00:08:43,200 we will verify your installed Python 149 00:08:43,200 --> 00:08:45,400 version. Just wait. 150 00:08:46,799 --> 00:08:52,700 Done. Right. See guys, I told that by default, right, your Python 151 00:08:52,700 --> 00:08:55,600 will install under the location of '/usr/local/bin' 152 00:08:55,700 --> 00:08:59,700 if you don't provide any prefix while running your 'configure'. 153 00:09:01,000 --> 00:09:03,800 If you don't provide any prefix means, where you want to install. 154 00:09:03,800 --> 00:09:06,700 If you don't, skip this, if you skip this path your Python 155 00:09:06,700 --> 00:09:08,900 will install under this location, '/usr/local/bin'. 156 00:09:09,300 --> 00:09:17,200 Just check it. 'ls -lrt /usr/local/bin', see the files 157 00:09:17,200 --> 00:09:19,400 what you are having, right? 158 00:09:19,400 --> 00:09:20,400 See the date. 159 00:09:21,600 --> 00:09:22,900 See, July 4th. 160 00:09:23,400 --> 00:09:26,800 So as of now we installed these files. 161 00:09:26,800 --> 00:09:29,100 [no audio] 162 00:09:29,100 --> 00:09:30,600 Now, this is your Python, 163 00:09:31,500 --> 00:09:35,500 right, and this is your 'pip', and see that the name is 'python3.7'. 164 00:09:35,500 --> 00:09:40,800 It is not like Python because on your Unix-like systems by default 165 00:09:40,800 --> 00:09:43,300 your Unix-like system will depend on any one of the Python 166 00:09:43,300 --> 00:09:46,000 version, and it is there by default with your operating system. 167 00:09:46,700 --> 00:09:50,100 Now if you install any other Python versions, right, Python3, 168 00:09:50,100 --> 00:09:54,000 or even any Python 2 also, right, you have to provide some different 169 00:09:54,000 --> 00:09:58,700 name. Anyway, we are installing Python 3. On my host already 170 00:09:58,700 --> 00:10:01,400 I have Python 2, that's why by default Python is giving some 171 00:10:01,400 --> 00:10:04,600 name 'python3.7', right. Now, 172 00:10:04,600 --> 00:10:09,000 you can verify your Python 3.7 by entering into this location. 173 00:10:09,100 --> 00:10:14,100 Let me enter into 'usr/local/bin', and let me provide 174 00:10:14,100 --> 00:10:20,500 './python 3.7 --version', right? 175 00:10:20,500 --> 00:10:23,100 So you have now your Python version here, 176 00:10:24,900 --> 00:10:26,500 some 3.7.0. 177 00:10:27,400 --> 00:10:30,800 Guys, if you observe, previously whenever if you run our 'python' 178 00:10:30,900 --> 00:10:35,200 command 'version', we are running in this way, but here I am 179 00:10:35,200 --> 00:10:39,100 using './'. If I don't use './', see that how you're 180 00:10:39,100 --> 00:10:43,200 going to get 'python 3.7 --version'. 181 00:10:43,200 --> 00:10:45,000 [no audio] 182 00:10:45,000 --> 00:10:51,800 Now, come out from this location, and check it. 'python 3.7 --version', 183 00:10:51,800 --> 00:10:52,800 and observe the output. 184 00:10:52,800 --> 00:10:54,600 [no audio] 185 00:10:54,600 --> 00:10:59,700 Right. You are getting your Python 3.7 version, or which Python 186 00:10:59,900 --> 00:11:05,100 3.7? '/usr/local/bin/python3.7', and see that 187 00:11:05,100 --> 00:11:06,100 'echo $path'. 188 00:11:06,100 --> 00:11:08,000 [no audio] 189 00:11:08,000 --> 00:11:12,600 See your 'usr/local/bin' is already there in your system path, 190 00:11:12,600 --> 00:11:16,600 that's why your python 3.7 is also able to be identified by 191 00:11:16,600 --> 00:11:18,600 your operating system. 192 00:11:18,900 --> 00:11:21,200 Now, I don't want use like Python 3.7, 193 00:11:21,200 --> 00:11:25,400 I want to use like Python 3, then is there any word called 194 00:11:25,400 --> 00:11:28,200 Python 3? No. You just try to create one soft link. 195 00:11:28,300 --> 00:11:30,600 Let me create, So where we are? 196 00:11:31,300 --> 00:11:32,800 Let me enter into that location. 197 00:11:32,800 --> 00:11:34,800 [no audio] 198 00:11:34,800 --> 00:11:37,300 Now what I am doing is I'm creating a soft link called 199 00:11:37,300 --> 00:11:44,000 'ln -s', your 'python3.7' to simply 'python3'. 200 00:11:45,100 --> 00:11:46,500 Now I can run from anywhere 201 00:11:46,500 --> 00:11:47,900 simply 'python3'. 202 00:11:47,900 --> 00:11:50,100 [no audio] 203 00:11:50,100 --> 00:11:52,400 That's it. Right. 204 00:11:52,600 --> 00:11:59,300 Now one more thing. You have here 'pip 3' for Python 3. To manage 205 00:11:59,400 --> 00:12:02,600 your packages or modules with your Python 3 206 00:12:02,600 --> 00:12:04,100 we have the 'pip' command, right? 207 00:12:04,400 --> 00:12:06,600 So but here the name is 'pip.3.7' 208 00:12:06,600 --> 00:12:09,900 Sorry 'pip3.7', but I don't want to use in this way, 209 00:12:09,900 --> 00:12:14,400 I mean 'pip3.7', I want to use like 'pip3'. But anyway don't create 210 00:12:14,400 --> 00:12:17,700 like 'pip' because already 'pip' is there with Python so that's 211 00:12:17,700 --> 00:12:19,000 why I'm creating 'pip3'. 212 00:12:20,500 --> 00:12:27,000 Right. Let me create again soft link for this 'ln - s pip3.7', simply 213 00:12:27,300 --> 00:12:28,800 'pip3', that's it. 214 00:12:28,800 --> 00:12:31,000 [no audio] 215 00:12:31,000 --> 00:12:36,900 Right. Now simply 'pip3 --version. Now come out from 216 00:12:36,900 --> 00:12:41,000 here or exit from that root, and from anywhere 217 00:12:41,000 --> 00:12:46,200 you can run now your 'python' command in this way, 'python'. Only 218 00:12:46,200 --> 00:12:51,700 python. will give you python 2.x version, and 'python3 --version' 219 00:12:51,700 --> 00:12:54,600 will give you now your Python 3 details. The same 220 00:12:54,600 --> 00:12:57,300 way only 'pip' is for your Python 2. 221 00:12:58,800 --> 00:13:03,400 Now 'pip3' is for Python 3. That's it. 222 00:13:03,400 --> 00:13:07,400 [no audio] 223 00:13:07,400 --> 00:13:08,400 Right. 224 00:13:09,200 --> 00:13:14,400 Okay. So guys whatever the steps we've done as of now, right, all those 225 00:13:14,400 --> 00:13:15,400 are these things. 226 00:13:16,700 --> 00:13:20,900 So guys, you know something like Ubuntu, in that distribution 227 00:13:21,100 --> 00:13:23,900 already you have some Python 3.6, something like that. 228 00:13:23,900 --> 00:13:26,500 If you want to use that also you can use it. No problem. 229 00:13:27,800 --> 00:13:31,400 Okay. Whatever it may be we need some Python 3.x, but here we install 230 00:13:31,400 --> 00:13:33,000 Python 3.7.0. 231 00:13:33,900 --> 00:13:37,100 Right. Because we are going to work with Python 3.x, and 232 00:13:37,100 --> 00:13:39,500 especially I am using python 3.7.0, 233 00:13:39,700 --> 00:13:42,200 that's why I installed this. Okay. 234 00:13:43,000 --> 00:13:45,000 Okay guys, thank you for watching this video. 235 00:13:45,000 --> 00:13:52,618 [no audio]