Home > Articles > Open Source > Python

📄 Contents

  1. Introduction to Python 3
  2. Obtaining and Installing Python 3
  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

For Windows and Mac OS X, easy to use graphical installer packages are provided that take you step by step through the installation process. These are available from www.python.org/download. Three separate installers are provided for Windows—download the plain "Windows installer" unless you know for sure that your machine has an AMD64 or Itanium processor in which case download the processor-specific version. Once you've got the installer, just run it and follow the on-screen instructions.

For Linux, BSD, and other Unices the easiest way to install Python is to use your operating system's package management system. In most cases Python is provided in several separate packages. For example, on Fedora, there is python for Python and python-tools for IDLE—a simple development environment—but note that these packages are only Python 3-based if you have an up to date Fedora, (10 or later). Similarly for Debian-based distributions such as Ubuntu the packages are python3 and idle3.

If no Python 3 packages are available for your operating system you will need to download the source from www.python.org/download and build Python from scratch. Get either of the source tarballs and unpack it using tar xvfz Python-3.0.tgz if you got the gzipped tarball or tar xvfj Python-3.0.tar.bz2 if you got the bzip2 tarball. The configuration and building are standard. First, change into the newly created Python-3.0 directory and run ./configure. (You can use the --prefix option if you want to do a local install.) Next run make.

It is possible that you may get some messages at the end saying that not all modules could be built. This normally means that you don't have the corresponding libraries on your machine. For example, if the readline module could not be built, use the package management system to install the corresponding development library, for example readline-devel on Fedora-based systems and readline-dev on Debian-based systems. (Unfortunately, the relevant package names are not always so obvious.) Once the missing packages are installed run ./configure and make again.

After successfully making you could run make test to see that everything is okay, although this is not necessary and can take many minutes to complete.

If you used --prefix to do a local installation, just run make install. You will probably want to add a soft link to the python executable (for example, ln -s ~/local/python3/bin/python ~/bin/python3, assuming you used --prefix=$HOME/local/python3 and you have a $HOME/bin directory that is in your PATH. You might also find it convenient to add a soft link to IDLE (for example, ln -s ~/local/python3/bin/idle ~/bin/idle3, on the same assumptions as before.)

If you did not use --prefix and have root access, log in as root and do make install. On sudo-based systems like Ubuntu, do sudo make install. If Python 2 is on the system /usr/bin/python won't be changed and Python 3 will be available as python3, and similarly Python 3's IDLE as idle3.

  • + Share This
  • 🔖 Save To Your Account