How To Install Python
How to Install Python
Python is a very powerful programming language and it is available on a wide variety of platforms which includes Windows, Linux and Mac OS X. To start using Python, you’ve to understand how to set up the Python environment.
Getting Started with Python Installation:
Local Development Setup
We have to setup the local development before anything else. So if you are using Linux or Mac OS X, open the terminal window and type “python” to check if it’s installed already. Most Linux don’t come with Python while Windows don’t even come with it at all. However, Mac usually come with python in every of its version.
That is to say most Mac users don’t need to download, install and set up python since it is configured by default. In case you encountered error, it means python is not installed or the python path is probably not configured.
There are two major Python versions: 2.7 and 3.x. However, I’ll be using 2.7 in this tutorial, but it does not really matter what version you use. So if you don’t have it installed on your machine, you’ll need to get it manually. The latest and current source code, binaries, documentation, news, etc., is always available on the Python official website https://www.python.org/.
Python distribution is available for a broad range of operating systems. So you only need to download only the binary code appropriate for your platform and install Python.
In case the binary code for your platform is not available, you’ll need a C compiler to compile the source code manually. But, compiling the source code manually offers more flexibility in terms of features you want in your installation.
Installing Python on Various Platforms:
Below is a quick overview of installing Python on various platforms −
Unix and Linux Installation
Below are the simple steps to install Python on Unix/Linux Os.
Head over to https://www.python.org/downloads/ in your Web browser.
Then follow this Python Source to download the zipped source code available for Unix/Linux.
Download, Unzip and Extract the files in a directory.
You can edit the Modules/Setup file if you want to customize some options.
Open a terminal in this directory, then enter run the command below:
run ./configure script
With that, it installs Python at the standard location /usr/local/bin and its libraries at /usr/local/lib/pythonXX where XX is the version of the Python.
You can also install python without downloading it from the official site, but through the terminal.
Enter the following command to install python version 2.x:
$ sudo apt-get install python2.6
Enter the following command to install python version 3.x:
$ sudo apt-get install python3.1
Red Hat/ RHEL / CentOS Linux user
Enter the following command:
$ sudo yum install python
# yum install python
Below are the steps to install Python on Windows machine.
As usual visit the download page https://www.python.org/downloads/ in a Web browser.
Then follow this link here for the Windows installer python-XYZ.msi file where “XYZ” is the version you want to install.
The Windows system you are using must have support Microsoft Installer 2.0 in order to use this installer python-XYZ.msi. Download and save the installer file to your local machine, then run the downloaded file.
This will bring up the Python install wizard, which is really easy to use. Just accept the default settings, wait until the install is finished, and you are done.
You might also need to download and install Python on Mac since most of the recent Macs that comes with Python installed have several years of outdated python version. You can visit the http://www.python.org/download/mac/ for guides on download and installing the current version along with extra tools to support development on the Mac.
MacPython is available, for older Mac OS's before Mac OS X 10.3 (released in 2003). Jack Jansen maintains it and you can have free full access to the entire documentation at his official website http://www.cwi.nl/~jack/macpython.html.
You can download the Mac OS X 64-bit/32-bit installer (not the PPC installer) from the Python website.
Run the downloaded file and install it.
Do remember that if you have Gatekeeper enabled, it will be blocked. So navigate to System Preferences > Security & Privacy and click Open Anyway.
Just click on Continue, Agree and Install buttons in the Install Python window.
You can try typing python in the terminal to check if it is installed successfully.