How to Install Python (Environment Set-up)
In this section of the tutorial, we will discuss the installation of Python on various operating systems.
Installation on Windows
Visit the linkhttps://www.python.org/downloads/ to download the latest release of Python. In this process, we will install Python 3.6.7 on our Windows operating system.
Double-click the executable file, which is downloaded; the following window will open. Select Customize installation and proceed.
The following window shows all the optional features. All the features need to be installed and are checked by default; we need to click next to continue.
The following window shows a list of advanced options. Check all the options which you want to install and click next. Here, we must notice that the first check-box (install for all users) must be checked.
Now, we are ready to install python-3.6.7. Let’s install it.
Now, try to run python on the command prompt. Type the command python in case of python2 or python3 in case of python3. It will show an error as given in the below image. It is because we haven’t set the path.
To set the path of python, we need to the right click on “my computer” and go to Properties → Advanced → Environment Variables.
Add the new path variable in the user variable section.
Type PATH as the variable name and set the path to the installation directory of the python shown in the below image.
Now, the path is set; we are ready to run python on our local system. Restart CMD, and type python again. It will open the python interpreter shell where we can execute the python statements.
How to Install Python3 on MacOS
Introduction
Python is a high level, dynamic, general purpose language. It was developed by Guido Van Rossum in 1991. Python’s syntax allows developers to use fewer lines of code than any other programming language. It basically focuses on the code readability of program. Python 2.7 is installed by default on MacOS but we can install other versions like python 3.5 and 3.6.
In this tutorial, we are learning how to install Python 3.6.3 on the MAC Operating system.
Prerequisites
- MacOS
- Login as an administrator on terminal
Installation
There are following steps which are used while installing Python3 on MacOS.
1) Checking python’s version on the system
We can check which version of the Python is currently installed on our system. Generally, Python 2.7 is installed by default.
Let’s see how can we do it.
- $ python -version
It shows Python 2.7.10 is installed on the computer which is quite often.
2) Download Python 3.6.3
In order to install Python 3.6.3, we must download the latest version from its official website https://www.python.org/downloads/ . The file is downloaded in .pkg format which can be directly installed by using Installer command.
3) Install Python 3.6.3
Since the downloaded file already is in .pkg format hence no mounting is required and We can use installer command to install Python 3.6.3.
Let’s see how can we do it.
Since The installer is used with super user permissions hence sudo forces terminal to prompt the user to fill the admin password. The process installs the Python 3.6.3 to the root directory which is mentioned with the target option.
4) Verify Python3
To check which Python version is installed on the machine, we can use python -version command. Since by default installed version is Python 2.7.10 hence it shows python 2.7.10. but it gives us flexibility to check the version of Python 3 on our computer.
Let’s see how can we use python 3 to check which version of python 3 is running.
- $ python -version
5) Working on Python’s script mode
To work on Python command line, we simply type python3 on the terminal. Python shell open where we can run Python statements such as print statements as we did here.
To run a Python file (.py) on the terminal, we simply type the file name and the file will be interpreted.
Well, we have installed Python3 on our MacOS.
How to Install Python 3 on CentOS
Introduction
Python is a high level, dynamic, general purpose language. It was developed by Guido Van Rossum in 1991. Python’s syntax allows developers to use fewer lines of code than any other programming language. It basically focuses on the code readability of program. Python 2.7 is installed by default on CentOS but we can install other versions like Python 3.5 and 3.6. In this tutorial, we are learning how to install Python 3.6.3 on CentOS.
Prerequisites
- CentOS
- Login as an administrator on the terminal
- Yum must be configured on the system.
Installation
Installation includes following steps.
1. Install IUS community Repository
In order to install Python 3.6 on CentOS, we need to first install IUS community repository which provides extra packages for Enterprise Linux. Execute the following command to install IUS community repository.
- $ sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
2. Install Python 3
Execute the following command to install python 3.6 on CentOS.
- $ sudo yum install python36u
3. Verify Python
To verify if we have installed correct version of python, we just need to type python3.6 -V on the terminal. The command will show the version installed which is 3.6.4 in my case.
4. Working on Python’s script mode
Just type python3.6 on the terminal to enter the Python’s script mode. We can execute the python statements on this shell. Since, python 2 is by default installed on CentOS, hence typing python on the terminal takes us to the python2 shell, hence we have to type python3.6 to work on the desired python shell.
Execute the valid python statements which get interpreted and show the desired output on the terminal as shown below.
Hence, we have installed and get started with Python 3.
How to install Python on Ubuntu 16.04 LTS?
Introduction
Python is a high level, dynamic and general purpose programming language. It was designed and developed by Python Software Foundation.
Python is a cross-platform language and was first released on 20, February 1991.
In this tutorial, we are working on the installation process of Python that includes the following steps.
Although Python 2.7 is installed by default in Ubuntu, but we can install other Python versions like python3.
To install python3, just type the following command in the terminal and it will be installed automatically.
Python Installation
1) Update the APT Repository
- $ apt-get update
2) Install Python
- $ apt-get install python3.6
2) Verify Python
When we type python it shows default installed python that is 2.7.
- $ python
For Python3 type the following command, then it will show the other version as well.
- $ python3
Well, on the basis of these commands, we can test application for both Python versions.