LanguagesPython Study Guide: Downloading and Installing Python

Python Study Guide: Downloading and Installing Python

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

In “Python Study Guide: Installing Python,” the first article of this series, you learned the basics of installing Python. In this article, I’ll walk you through the process of installing Python on Windows, Mac OSX, and a popular variety of Linux. (Other Linux distributions will be similar.)

Which Python?

Python 3, the current version, was released in October of 2008. This was a non–backward-compatible release, which meant that many existing Python 2 projects couldn’t upgrade. Consequently, you’ll still see a lot of Python 2 around. However, if you are just learning or are beginning a new project, you’ll definitely want to go with Python 3.

The Multiplatform, No-Install Solution

But before that, you should know that you don’t actually have to install Python at all to get started! All you have to do is visit the Python.org site. There, you’ll see a text window where you can begin typing in code, see it immediately run, and view the results. This is a super-easy way to get started and might serve as a useful place to let you try out Python ideas and code while on the go. However, it’s not a development environment for creating complete applications.

Python on Windows

Although some companies may bundle Python with a Windows computer, most do not. To check, click Win+r, type python3, and press Enter. If it launches, check to see what version you have. If you get the “Bad command or filename,” you’re out of luck.

A note on versions: If you are running Windows Vista or newer, you will be able to run Python 3.5 (the latest release as of this writing). However, if you are using Windows XP, you’ll need to install Python 3.4.

To install Python, use your Windows machine to browse to the Windows Python downloads page, where you’ll find a big friendly button for downloading the latest version. For previous versions, you can scroll down the page.

Install1
Figure 1: The Windows installation screen

Click to check the box at the bottom of the dialog, Add Python 3.5 to PATH. Then, click Install Now. You may see a User Account Control dialog asking to allow the app to make changes to your PC. Click OK. After a short wait, you’ll the Setup was successful dialog. Click Close; you’re ready to go!

Python on Mac OSX

All versions since OSX Tiger include a version of Python 2, but none (yet) come with Python 3. To verify, open a terminal and enter python3.

To install it, go to the Mac Python downloads page and click the button at the top to download the latest version. (This page senses the OS of the person visiting and presents the appropriate download button.) Once the download is complete, double-click the file to begin the install process.

Install2
Figure 2: The Macintosh installation screen

Click Continue. And, click it a couple more times to get through the read-me and the license agreement. Select the drive where it should be installed and, finally, click Install. You may need to enter your password at this point to give the provide authorization. (When did Mac installations become more tedious than Windows installations?)

Once it’s done, you’re good to go!

Python on Linux

Most modern Linuxes have some version of Python installed. To see if it’s Python 3, type python3 at the terminal. If it’s not there or if you want to upgrade, the following should help.

To install or update Python 3 on Debian and similar distributions, you can use…

sudo apt-get install python3

On FreeBSD, use:

pkg_add -r python

On OpenBSD, use:

pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/
   <insert your architecture here>/python-<version>.tgz

On OpenSolaris, you can get Python from OpenCSW. Use:

pkgutil -i python35

For other varieties of *nix, do a search for your distribution and Python 3. In some cases, the easiest approach might be to simply download the source, open the tar, and run make to compile it locally. For example, on CentOS 7/6, REHL 7/6m and Fedora Cloud, you do a recompile like this…

# wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
# tar xzf Python-3.5.0.tgz
# cd Python-3.5.0
# ./configure --prefix=/usr/local
# make altinstall

Once that’s complete, you can check the install and Python version.

# python3.5 -V
Python 3.5.0

Don’t Have a Platform? You Can Buy One for Only $35…

Python is also the language of choice of the $35 Raspberry Pi computer. This little green board, about the height/width of an index card, is a full blown computer; just plug in a monitor and mouse and you’re ready to go! The Pi runs a variant of Linux, called Raspbian, that features Python as its pre-installed, preferred language. So if you’re an aspiring Maker, Python is there for you!

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories