Chapter 0. Installing Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
– ancient Roman proverb
‣ show table of contents
Before you can start programming in Python 3, you need to install it. Or do you?
Which Python Is Right For You?#
If you’re using an account on a hosted server, your isp may have already installed Python 3. If you’re running Linux at home, you may already have Python 3, too. Most popular GNU/Linux distributions come with Python 2 in the default installation; a small but growing number of distributions also include Python 3. Mac OS X includes a command-line version of Python 2, but as of this writing it does not include Python 3. Microsoft Windows does not come with any version of Python. But don’t despair! You can point-and-click your way through installing Python, regardless of what operating system you have.
The easiest way to check for Python 3 on your Linux or Mac OS X system is from the command line. Once you’re at a command line prompt, just type python3 (all lowercase, no spaces), press ENTER, and see what happens. On my home Linux system, Python 3.1 is already installed, and this command gets me into the Python interactive shell.
Python 3.1 (r31:73572, Jul 28 2009, 06:52:23)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
(Type exit() and press ENTER to exit the Python interactive shell.)
My web hosting provider also runs Linux and provides command-line access, but my server does not have Python 3 installed. (Boo!)
Bash: python3: command not found
So back to the question that started this section, “Which Python is right for you?” Whichever one
runs on the computer you already have.
[Read on for Windows instructions, or skip to Installing on Mac OS X, Installing on Ubuntu Linux, or Installing on Other Platforms.]
Installing on Microsoft Windows#
Windows comes in two architectures these days: 32-bit and 64-bit. Of course, there are lots of different versions of Windows – XP, Vista, Windows 7 – but Python runs on all of them. The more important distinction is 32-bit v. 64-bit. If you have no idea what architecture you’re running, it’s probably 32-bit.
Visit python. org/download/ and download the appropriate Python 3 Windows installer for your architecture. Your choices will look something like this:
Python 3.1 Windows installer (Windows binary – does not include source)
Python 3.1 Windows AMD64 installer (Windows AMD64 binary – does not include source)
I don’t want to include direct download links here, because minor updates of Python happen all the time and I don’t want to be responsible for you missing important updates. You should always install the most recent version of Python 3.x unless you have some esoteric reason not to.
Once your download is complete, double-click the. msi file. Windows will pop up a security alert, since you’re about to be running executable code. The official Python installer is digitally signed by the Python Software Foundation, the non-profit corporation that oversees Python development. Don’t accept imitations!
Click the Run button to launch the Python 3 installer.
The first question the installer will ask you is whether you want to install Python 3 for all users or just for you.