[no audio]
Hi friends, here
we are going to see how to install Python on your Linux or
any Unix-like systems or 'Installing required Python on Linux'.
See why I am saying, 'Installing required Python on Linux', because
if we go with any one of the Unix-like systems, most
of the Unix-like systems are already configured with anyone
of the Python version based on the release of your Linux
kernel. Right. Now let me open
my OS. So this is Linux,
or more specifically it is
Amazon Linux,
okay, and it is released in 2018, March.
Now if I run simply see 'python --version' you're getting
some Python 2.7.16, means this is the default version
for this Linux.
And you can also have your
[no audio]
'pip --version' as well.
I mean 'pip' is also configured.
So by default most of the Unix-like systems are configured
with your Python, and you may get, that version maybe 2.5 or
2.7 or 2.6, whatever it maybe based on when it was released,
I mean your Linux, when it was released, and but here I need
some 3.x version.
Suppose, let us say 3.7.0
I need on this host,
on your Linux,
so guys first of all before going to install your required
Python version on your any Unix-like systems don't disturb
existing Python because your 'm' command will depend on your
Python, or some operations on your Unix-like
systems will depend on your Python
that's why don't disturb the existing Python version.
[no audio]
I mean whenever if you're going to install any new Python
don't take name as 'python'. Instead of that 'python',
let's say 'pythonx', 'pythony', something like that, or 'python3',
in that way just take the name for your Python software,
right? So in that way you have to install. And first let me
enter into root. Because I have to install this python so
I should be the root user, or you can also run from any user,
for that you should have some root privileges.
So instead of all confusions first I enter into root, now
I am the root user.
Right. Now you have some steps guys,
very simple steps.
Let me go with very first step.
See let me open your official website 'python.org'.
[no audio]
So, you know by default you have some 'Download' tab, then
there you can see 'View the full list of downloads', and here you
can select your required operating system.
I'm going to work with Unix-like systems, then simply
I'm clicking on 'Linux/Unix'.
Now see you have latest releases, but I need suppose 3.7.0,
let me go and see somewhere my 3.7.0. Here
I'm having my 3.7.0.
Right. So let me download your 'source tarball'.
So to download that on your Unix-like systems, from command
line of your Unix-like systems
you can download. So for that just copy the link location
of your required Python software.
[no audio]
I copied the link location. Now go to here and first check
whether 'wget' command is there or not. If it is not there
just simply run 'sudo yum install wget'.
Right. Already there, that's why it is not installing.
Then let me enter into any location.
So I'm entering into '/opt/'.
So there I am going to download my Python software, Python
'tar source wall, right. After that
now see that. Just now you downloaded
your required Python package.
Now, you have to extract it.
[no audio]
Right. So to extract that simply use 'tar -xvzf'. So here
'v' for 'verbose'. You can see the information while extracting.
That's it.
Right. Now you have your extracted package.
Now you can go and install your Python, but before going
to install your Python, right, actually this is a source file,
you need to compile. To compile that you need some compiler
and some packages as well.
I mean some dependencies you need to install your
Python on your host.
So I have a list of dependencies, right, just before going
to install your Python
just run this command 'yym install', your 'gcc
openssl - devel', right, all those things you have to install.
[no audio]
Once if we install all these dependencies, all these packages,
right, now just navigate into your extracted directory, or
extracted Python package, and there if you observe you have
some 'configure', now run './configure' command first.
So here guys, basically your './configure' you are going
to provide to check your configuration details along with
that you can also provide the path where you want to install
your Python, with this option '--prefix'. Then suppose
I want to install somewhere '/usr'
some '/bin' location, yes you can provide your path, or if you
skip this value, '--prefix' value, by default your 'configure'
will install, right, your Python package, required Python under
'/usr/local/bin'. In this location by default
it will install. So I want to install in that location only,
that's why I'm not giving any prefix, right. And you can also
use some '--enable-optimizations', right, if you provide this
option it will take some time so you can check it by providing
'--enable-optimizations'. But I am not giving that because
it will take some time, right.
You can just try, or you can also try simply './configure',
just 'Enter'.
[no audio]
So it will take some time to configure your details on your host.
[no audio]
So after configuration, simply you have to compile your
code, I mean your, whatever the package you download it,
right, that you have to compile.
So for that you need to run a command called 'make', so that
you are going to compile your code.
[no audio]
Right. Yes, done.
Now, let me run 'make', and before that observe that it is also giving
a suggestion called 'Please run ./configure --
enable-optimizations', right to give this information.
But anyway I'm not running that, you can try it, right. Now
after configuration
just run 'make'. So 'make' is nothing but you are going to compile
your downloaded, your Python source code. Once if we compile
then you can install, right.
So now I am compiling.
So it will take some time. Again,
just wait for some time.
So once it is done then we'll go and install.
[no audio]
So still it is compiling your Python package.
Yes, your compilation is done.
Now simply run 'make'.
[no audio]
So guys in case if we have, if we don't
have any previously installed Python versions, then simply
you can run 'make install', but we already have Python version,
and you don't want to disturb that that's why use
'make altinstall', and 'Enter'.
Now it is going to install your Python.
Right. Again, it will take some time. Just wait.
So once it is done then
we will verify your installed Python
version. Just wait.
Done. Right. See guys, I told that by default, right, your Python
will install under the location of '/usr/local/bin'
if you don't provide any prefix while running your 'configure'.
If you don't provide any prefix means, where you want to install.
If you don't, skip this, if you skip this path your Python
will install under this location, '/usr/local/bin'.
Just check it. 'ls -lrt /usr/local/bin', see the files
what you are having, right?
See the date.
See, July 4th.
So as of now we installed these files.
[no audio]
Now, this is your Python,
right, and this is your 'pip', and see that the name is 'python3.7'.
It is not like Python because on your Unix-like systems by default
your Unix-like system will depend on any one of the Python
version, and it is there by default with your operating system.
Now if you install any other Python versions, right, Python3,
or even any Python 2 also, right, you have to provide some different
name. Anyway, we are installing Python 3. On my host already
I have Python 2, that's why by default Python is giving some
name 'python3.7', right. Now,
you can verify your Python 3.7 by entering into this location.
Let me enter into 'usr/local/bin', and let me provide
'./python 3.7 --version', right?
So you have now your Python version here,
some 3.7.0.
Guys, if you observe, previously whenever if you run our 'python'
command 'version', we are running in this way, but here I am
using './'. If I don't use './', see that how you're
going to get 'python 3.7 --version'.
[no audio]
Now, come out from this location, and check it. 'python 3.7 --version',
and observe the output.
[no audio]
Right. You are getting your Python 3.7 version, or which Python
3.7? '/usr/local/bin/python3.7', and see that
'echo $path'.
[no audio]
See your 'usr/local/bin' is already there in your system path,
that's why your python 3.7 is also able to be identified by
your operating system.
Now, I don't want use like Python 3.7,
I want to use like Python 3, then is there any word called
Python 3? No. You just try to create one soft link.
Let me create, So where we are?
Let me enter into that location.
[no audio]
Now what I am doing is I'm creating a soft link called
'ln -s', your 'python3.7' to simply 'python3'.
Now I can run from anywhere
simply 'python3'.
[no audio]
That's it. Right.
Now one more thing. You have here 'pip 3' for Python 3. To manage
your packages or modules with your Python 3
we have the 'pip' command, right?
So but here the name is 'pip.3.7'
Sorry 'pip3.7', but I don't want to use in this way,
I mean 'pip3.7', I want to use like 'pip3'. But anyway don't create
like 'pip' because already 'pip' is there with Python so that's
why I'm creating 'pip3'.
Right. Let me create again soft link for this 'ln - s pip3.7', simply
'pip3', that's it.
[no audio]
Right. Now simply 'pip3 --version. Now come out from
here or exit from that root, and from anywhere
you can run now your 'python' command in this way, 'python'. Only
python. will give you python 2.x version, and 'python3 --version'
will give you now your Python 3 details. The same
way only 'pip' is for your Python 2.
Now 'pip3' is for Python 3. That's it.
[no audio]
Right.
Okay. So guys whatever the steps we've done as of now, right, all those
are these things.
So guys, you know something like Ubuntu, in that distribution
already you have some Python 3.6, something like that.
If you want to use that also you can use it. No problem.
Okay. Whatever it may be we need some Python 3.x, but here we install
Python 3.7.0.
Right. Because we are going to work with Python 3.x, and
especially I am using python 3.7.0,
that's why I installed this. Okay.
Okay guys, thank you for watching this video.
[no audio]