<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">
Defrag This

| Read. Reflect. Reboot.

How Do You Install Python?

Adam Bertram| October 03 2017

| IT insights

To kick off our series on Python from a PowerShell guy’s perspective, the first thing we have to do is install Python.

Since Python is generally used on Linux and MacOS, it’s also cross platform, so it works on Windows as well. To ensure we’re able to use Python regardless of the operating system we’re using, we’re going to go over how to get Python up and running on both Windows and Linux/MacOS.

how-to-install-python.jpg

Determining Currently Installed Version

Unlike Windows, Python typically comes pre-installed on many *nix operating systems and MacOS. On the computer I’ll be using running MacOS Sierra, Python 2.7 was installed. To determine if you already have Python installed, fire up your terminal and type python --version or python -V. This will immediately display what version is installed.

However, this is not entirely accurate. Unlike PowerShell, Python can be installed in a few different places, and you might actually have multiple versions installed. Running the python executable only executes the python defined in your PATH environment variable.

Also, the alias python will generally refer to any 2.x version. If you have Python 3.x installed, you will also have the python3 alias.

 $ python -V
Python 2.7.10
$ python --version
Python 2.7.10
$ python3 --version
Python 3.6.2
$ python3 -V
Python 3.6.2
$

You can see above that I have both 2.7.10 and 3.6.2 installed.

MacOS

It is recommended to not use Python 2 anymore. There seem to be a lot of code still out there running 2.x, but 3.x is the way of the future and I’d like to ensure I have that installed on my machine.

On MacOS, the recommended way to get Python 3.x on your machine is to use the HomeBrew utility. HomeBrew is a package manager similar to the PowerShell Gallery that allows users to download and install programs from a public repository.

 $ brew install python3
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
.....

Error: python3 3.6.0 is already installed
To upgrade to 3.6.2, run `brew upgrade python3`

$ brew upgrade python3
==> Upgrading 1 outdated package, with result:
python3 3.6.2
==> Upgrading python3
==> Installing dependencies for python3: readline, sqlite, gdbm, openssl
......
==> Summary
🍺  /usr/local/Cellar/python3/3.6.2: 3,598 files, 55.9MB

You can see above that HomeBrew already knew that I had an older version of Python 3 installed and prompted me to upgrade which I did. I now have Python 3.6.2 installed and am up to date. I can test it out by running python3 and noticing the header.

 $ python3
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Linux

Installing Python on Linux is also just as straightforward as MacOS.

To install Python on Ubuntu 16.10 or newer, we can use the apt-get package manager.

$ sudo apt-get update
$ sudo apt-get install python3.6

In Fedora, we could do:

$ sudo dnf install python3

Windows

Installing Python on Windows is as straightforward as any standard MSI package you’re used to installing. Since Windows doesn’t have Python installed by default, this is a must. You’ll first need to head over to the Windows download section on python.org and grab the appropriate installer. I’m going to choose the Windows x86-64 executable installer because it will be the easiest.

Once you’ve got the installer download, simply run it, click Install, wait for a bit, and you’re done.

python-windows.png

Wrap Up

As you can see, getting Python installed on any platform is straightforward if using one of the packages manages for Linux/MacOS. Installing Python is the easy part but using Python and getting used to how things work the Python way is going to be a completely different story! Stay tuned…

python.jpg

Topics: IT insights

Leave a Reply

Your email address will not be published. Required fields are marked *

THIS POST WAS WRITTEN BY Adam Bertram

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.