O'Reilly Introduction to Python/Section 1/Linux set up Python



In this section, we are going to check which version of Python is installed, and possibly install a newer version.

Check your Python installation
 Start up a Terminal. You can find the Terminal application at Applications/Accessories/Terminal, or it may already be on your menu bar.

This Terminal is another way of navigating your computer and running programs -- just textually instead of graphically. We are going to be running Python and Python scripts from this Terminal.  Test your Python installation at the Terminal prompt by typing

python

and pressing Enter. You should see something like Python 3.4.1 (v3.4.1:d047928ae3f6, May 13 2013, 12:45:22) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 

You just started Python! The  indicates that you are at a new type of prompt -- a Python prompt. The Terminal prompt lets you navigate your computer and run programs, and the Python prompt lets you write and run Python code interactively.

 Exit the Python prompt by typing

exit

and pressing Enter. This will take you back to the Linux Terminal prompt. 

If your Python version started with a 3, you are done with this section; please &laquo; return to the Section 1 main page

If your Python version started with a 2, you may have a version of Python 3 installed, just not as the default Python. Type

python3

at a Terminal prompt.

If this starts Python, you have a version of Python 3 installed, just not as the default Python. Please use the command python3 instead of python to start Python for the rest of this course.

If you have no version of Python 3 installed, we'll need to install it. Please continue to the instructions in the next section.

Install Python
Please install Python 3.4 using your package manager, or from source using the source release here.

Please use the command python3 instead of python to start Python for the rest of this course.

Success!
You have tested your Python installation.



&laquo; Back to the Section 1 main page