Skip to content

Commit d8b2e4a

Browse files
author
Mark Pilgrim
committed
more troubleshooting
1 parent 241b66f commit d8b2e4a

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

installing-python.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,20 @@ <h2 id=which>Which Python Is Right For You?</h2>
2828

2929
<p>If you're using an account on a hosted server, your <abbr>ISP</abbr> may have already installed Python 3. If you&#8217;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&#8217;t despair! You can point-and-click your way through installing Python, regardless of what operating system you have.
3030

31-
<p>The easiest way to check for Python 3 on your Linux or Mac OS X system is to get to a command line. On Linux, look in your <b><code>Applications</code></b> menu for a program called <b><code>Terminal</code></b>. (It may be in a submenu like <b><code>Accessories</code></b> or <b><code>System</code></b>.) On Mac OS X, there is an application called <b><code>Terminal.app</code></b> in your <code>/Applications/Utilities/</code> folder. (<a href=troubleshooting.html#running-python-on-the-command-line>More command line help</a> is available in the appendix.)
31+
<p>The easiest way to check for Python 3 on your Linux or Mac OS X system is <a href=troubleshooting.html#getting-to-the-command-line>from the command line</a>. Once you&#8217;re at a command line prompt, just type <kbd>python3</kbd> (all lowercase, no spaces), press <kbd>ENTER</kbd>, and see what happens. On my home Linux system, Python 3.1 is already installed, and this command gets me into the <i>Python <dfn>interactive shell</dfn></i>.
3232

33-
<p>Once you&#8217;re at a command line prompt, just type <kbd>python3</kbd> (all lowercase, no spaces) and see what happens. On my home Linux system, Python 3 is already installed, and this command gets me into the <i>Python <dfn>interactive shell</dfn></i>.
34-
35-
<pre class='nd screen'>
33+
<pre class='nd screen cmdline'>
3634
<samp class=p>mark@atlantis:~$ </samp><kbd>python3</kbd>
37-
<samp>Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52)
38-
[GCC 4.3.3] on linux2
35+
<samp>Python 3.1 (r31:73572, Jul 28 2009, 06:52:23)
36+
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
3937
Type "help", "copyright", "credits" or "license" for more information.
4038
>>></samp></pre>
4139

4240
<p>(Type <kbd>exit()</kbd> and press <kbd>ENTER</kbd> to exit the Python interactive shell.)
4341

4442
<p>My <a href=http://cornerhost.com/>web hosting provider</a> also runs Linux and provides command-line access, but my server does not have Python 3 installed. (Boo!)
4543

46-
<pre class='nd screen'>
44+
<pre class='nd screen cmdline'>
4745
<samp class=p>mark@manganese:~$ </samp><kbd>python3</kbd>
4846
<samp>bash: python3: command not found</samp></pre>
4947

j/dip3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ $(document).ready(function() {
143143
$(this).wrapInner('<div class=b></div>');
144144
var widgetHTML = '<div class=w>[<a class=toggle href="javascript:toggleCodeBlock(\'' + this.id + '\')">' + HS.visible + '</a>] [<a href="javascript:plainTextOnClick(\'' + this.id + '\')">open in new window</a>]';
145145
if ($(this).hasClass('cmdline')) {
146-
widgetHTML += ' [<a href="troubleshooting.html#running-python-on-the-command-line">command line help</a>]';
146+
widgetHTML += ' [<a href="troubleshooting.html#getting-to-the-command-line">command line help</a>]';
147147
}
148148
widgetHTML += '</div>';
149149
$(this).prepend(widgetHTML);

table-of-contents.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ <h1>Table of Contents</h1>
443443
<li id=troubleshooting><a href=troubleshooting.html>Troubleshooting</a>
444444
<ol>
445445
<li><a href=troubleshooting.html#divingin>Diving In</a>
446-
<li><a href=troubleshooting.html#running-python-on-the-command-line>Running Python on the Command Line</a>
446+
<li><a href=troubleshooting.html#getting-to-the-command-line>Getting to the Command Line</a>
447+
<li><a href=troubleshooting.html#running-python-on-the-command-line>Running Python on the command line</a>
447448
</ol>
448449
</ol>
449450
<!-- /toc -->

troubleshooting.html

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,54 @@ <h1>Troubleshooting</h1>
2020
<h2 id=divingin>Diving In</h2>
2121
<p class=f>FIXME
2222

23-
<h2 id=running-python-on-the-command-line>Running Python on the Command Line</h2>
24-
<p>Throughout this book, there are examples of executing Python programs from the command line.
23+
<h2 id=getting-to-the-command-line>Getting to the Command Line</h2>
24+
<p>Throughout this book, there are examples of executing Python programs from the command line. Where is the command line?
2525

2626
<p>On Linux, look in your <b><code>Applications</code></b> menu for a program called <b><code>Terminal</code></b>. (It may be in a submenu like <b><code>Accessories</code></b> or <b><code>System</code></b>.)
2727

28-
On Mac OS X, there is an application called <b><code>Terminal</code></b> in your <code>/Applications/Utilities/</code> folder. To get there, click on your desktop, open the <b><code>Go</code></b> menu, select <b><code>Go to folder...</code></b>, and type <kbd>/Applications/Utilities/</kbd>. Then run the <b><code>Terminal</code></b> program.
28+
<p>On Mac OS X, there is an application called <b><code>Terminal</code></b> in your <code>/Applications/Utilities/</code> folder. To get there, click on your desktop, open the <b><code>Go</code></b> menu, select <b><code>Go to folder...</code></b>, and type <kbd>/Applications/Utilities/</kbd>. Then double-click the <b><code>Terminal</code></b> program.
29+
30+
<p>On Windows, click <b><code>Start</code></b>, select <b><code>Run...</code></b>, type <kbd>cmd</kbd>, and press <kbd>ENTER</kbd>.
31+
32+
<h2 id=running-python-on-the-command-line>Running Python on the command line</h2>
33+
34+
<p>Once you <a href=#getting-to-the-command-line>get to the command line</a>, you should be able to run the Python interactive shell. On the Linux or Mac OS X command line, type <kbd>python3</kbd> and press <kbd>ENTER</kbd>. On the Windows command line, type <kbd>c:\python31\python</kbd> and press <kbd>ENTER</kbd>. If all goes well, you should see something like this:
35+
36+
<pre class='nd screen'>
37+
<samp class=p>you@localhost:~$ </samp><kbd>python3</kbd>
38+
<samp>Python 3.1 (r31:73572, Jul 28 2009, 06:52:23)
39+
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
40+
Type "help", "copyright", "credits" or "license" for more information.
41+
>>></samp></pre>
42+
43+
<p>(Type <kbd>exit()</kbd> and press <kbd>ENTER</kbd> to exit the Python interactive shell and go back to the command line. This works on all platforms.)
44+
45+
<p>If you get a &#8220;command not found&#8221; error, it probably means you <a href=installing-python.html>don&#8217;t have Python 3 installed</a>.
46+
47+
<pre class='nd screen'>
48+
<samp class=p>you@localhost:~$ </samp><kbd>python3</kbd>
49+
<samp>bash: python3: command not found</samp></pre>
50+
51+
<p>On the other hand, if you get into a Python interactive shell but the version number is not what you expected, you may have more than one version of Python installed. This happens most often on Linux and Mac OS X systems, where an older version of Python is pre-installed. You can install the latest version without deleting the older version (they will live side-by-side in peace), but you will need to be more specific when you run Python from the command line.
52+
53+
<p>For example, on my home Linux box, I have several versions of Python installed so I can test the Python software that I write. To run a specific version, I can type <code>python3.0</code>, <code>python3.1</code>, or <code>python2.6</code>.
54+
55+
<pre class='nd screen'>
56+
<samp class=p>mark@atlantis:~$ </samp><kbd>python3.0</kbd>
57+
<samp>Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52)
58+
[GCC 4.3.3] on linux2
59+
Type "help", "copyright", "credits" or "license" for more information.
60+
>>> </samp><kbd class=pp>exit()</kbd>
61+
<samp class=p>mark@atlantis:~$ </samp><kbd>python3.1</kbd>
62+
<samp>Python 3.1 (r31:73572, Jul 28 2009, 06:52:23)
63+
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
64+
Type "help", "copyright", "credits" or "license" for more information.
65+
>>> </samp><kbd class=pp>exit()</kbd>
66+
<samp class=p>mark@atlantis:~$ </samp><kbd>python2.6</kbd>
67+
<samp>Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
68+
[GCC 4.4.3] on linux2
69+
Type "help", "copyright", "credits" or "license" for more information.
70+
>>> </samp><kbd class=pp>exit()</kbd></pre>
2971

3072
<p class=v><a rel=prev href=where-to-go-from-here.html title='back to &#8220;Where To Go From Here&#8221;'><span class=u>&#x261C;</span></a> <a href=blank.html rel=next><span class=u>&#x261E;</span></a>
3173

0 commit comments

Comments
 (0)