O'Reilly Introduction to Python/Section 1/Linux set up Python: Difference between revisions
imported>Jesstess No edit summary |
imported>Jesstess No edit summary |
||
Line 1: | Line 1: | ||
[[File:Python-logo.png|300px]] |
[[File:Python-logo.png|300px]] |
||
In this section, we are going to check which version of Python is installed, and possibly install a newer version. |
|||
__TOC__ |
|||
== Check your Python installation == |
|||
<ol> |
<ol> |
||
Line 7: | Line 11: | ||
<br /> |
<br /> |
||
This Terminal |
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. |
||
</li> |
</li> |
||
<li>Test your Python |
<li>Test your Python installation at the Terminal prompt by typing |
||
<pre> |
<pre> |
||
Line 15: | Line 19: | ||
</pre> |
</pre> |
||
and |
and pressing Enter. You should see something like |
||
<pre> |
<pre> |
||
Python |
Python 3.4.1 (v3.4.1:d047928ae3f6, May 13 2013, 12:45:22) |
||
[GCC 4.3.2] on linux2 |
[GCC 4.3.2] on linux2 |
||
Type "help", "copyright", "credits" or "license" for more information. |
Type "help", "copyright", "credits" or "license" for more information. |
||
Line 24: | Line 28: | ||
</li> |
</li> |
||
You just started Python! The <code>>>></code> 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.<br /> |
|||
* If the Python version number (2.7.5 in the example above) is not a number between 2.4 and 2.7 (ignoring the number after the second dot), tell a staff member. |
|||
</li> |
</li> |
||
<li> |
<li>Exit the Python prompt by typing |
||
<pre> |
<pre> |
||
Line 34: | Line 36: | ||
</pre> |
</pre> |
||
and |
and pressing Enter. This will take you back to the Linux Terminal prompt.</li> |
||
</ol> |
</ol> |
||
<b>If your Python version started with a 3</b>, you are done with this section; please [[O'Reilly Introduction to Python/Section 1|« return to the Section 1 main page]] |
|||
<b>If your Python version started with a 2</b>, you may have a version of Python 3 installed, just not as the default Python. Type |
|||
<pre> |
|||
python3 |
|||
</pre> |
|||
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 <b>python3</b> instead of <b>python</b> 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 [https://www.python.org/downloads/release/python-341/ here]. |
|||
Please use the command <b>python3</b> instead of <b>python</b> to start Python for the rest of this course. |
|||
== Success! == |
== Success! == |
Latest revision as of 02:45, 27 May 2014
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 - Exit the Python prompt by typing
exit()
and pressing Enter. This will take you back to the Linux Terminal prompt.
>>>
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.If your Python version started with a 3, you are done with this section; please « 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.