You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: installing-python.html
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -28,22 +28,20 @@ <h2 id=which>Which Python Is Right For You?</h2>
28
28
29
29
<p>If you're using an account on a hosted server, your <abbr>ISP</abbr> 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.
30
30
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. (<ahref=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 <ahref=troubleshooting.html#getting-to-the-command-line>from the command line</a>. Once you’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>.
32
32
33
-
<p>Once you’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>.
Type "help", "copyright", "credits" or "license" for more information.
40
38
>>></samp></pre>
41
39
42
40
<p>(Type <kbd>exit()</kbd> and press <kbd>ENTER</kbd> to exit the Python interactive shell.)
43
41
44
42
<p>My <ahref=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!)
varwidgetHTML='<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>]';
145
145
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>]';
Copy file name to clipboardExpand all lines: troubleshooting.html
+45-3Lines changed: 45 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,54 @@ <h1>Troubleshooting</h1>
20
20
<h2id=divingin>Diving In</h2>
21
21
<pclass=f>FIXME
22
22
23
-
<h2id=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
+
<h2id=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?
25
25
26
26
<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>.)
27
27
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
+
<h2id=running-python-on-the-command-line>Running Python on the command line</h2>
33
+
34
+
<p>Once you <ahref=#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:
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 “command not found” error, it probably means you <ahref=installing-python.html>don’t have Python 3 installed</a>.
<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>.
Type "help", "copyright", "credits" or "license" for more information.
70
+
>>></samp><kbdclass=pp>exit()</kbd></pre>
29
71
30
72
<pclass=v><arel=prevhref=where-to-go-from-here.htmltitle='back to “Where To Go From Here”'><spanclass=u>☜</span></a><ahref=blank.htmlrel=next><spanclass=u>☞</span></a>
0 commit comments