diff --git a/installing-python.html b/installing-python.html index 459c185..0138aec 100755 --- a/installing-python.html +++ b/installing-python.html @@ -28,14 +28,12 @@ h2,.i>li{clear:both}

If you're using an account on a hosted server, your ISP 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. -

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 Applications menu for a program called Terminal. (It may be in a submenu like Accessories or System.) On Mac OS X, there is an application called Terminal.app in your /Applications/Utilities/ folder. (More command line help is available in the appendix.) +

The easiest way to check for Python 3 on your Linux or Mac OS X system is from the command line. Once you’re at a command line prompt, just type python3 (all lowercase, no spaces), press ENTER, and see what happens. On my home Linux system, Python 3.1 is already installed, and this command gets me into the Python interactive shell. -

Once you’re at a command line prompt, just type python3 (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 Python interactive shell. - -

+
 mark@atlantis:~$ python3
-Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52)
-[GCC 4.3.3] on linux2
+Python 3.1 (r31:73572, Jul 28 2009, 06:52:23) 
+[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>>
@@ -43,7 +41,7 @@ Type "help", "copyright", "credits" or "license" for more information.

My web hosting provider also runs Linux and provides command-line access, but my server does not have Python 3 installed. (Boo!) -

+
 mark@manganese:~$ python3
 bash: python3: command not found
diff --git a/j/dip3.js b/j/dip3.js index a0b1a7b..e85be68 100644 --- a/j/dip3.js +++ b/j/dip3.js @@ -143,7 +143,7 @@ $(document).ready(function() { $(this).wrapInner('
'); var widgetHTML = '
[' + HS.visible + '] [open in new window]'; if ($(this).hasClass('cmdline')) { - widgetHTML += ' [command line help]'; + widgetHTML += ' [command line help]'; } widgetHTML += '
'; $(this).prepend(widgetHTML); diff --git a/table-of-contents.html b/table-of-contents.html index 6bff129..ef7acdd 100755 --- a/table-of-contents.html +++ b/table-of-contents.html @@ -443,7 +443,8 @@ li ol{font-weight:normal}
  • Troubleshooting
    1. Diving In -
    2. Running Python on the Command Line +
    3. Getting to the Command Line +
    4. Running Python on the command line
    diff --git a/troubleshooting.html b/troubleshooting.html index fb8f0b4..7a2a638 100644 --- a/troubleshooting.html +++ b/troubleshooting.html @@ -20,12 +20,54 @@

    Diving In

    FIXME -

    Running Python on the Command Line

    -

    Throughout this book, there are examples of executing Python programs from the command line. +

    Getting to the Command Line

    +

    Throughout this book, there are examples of executing Python programs from the command line. Where is the command line?

    On Linux, look in your Applications menu for a program called Terminal. (It may be in a submenu like Accessories or System.) -On Mac OS X, there is an application called Terminal in your /Applications/Utilities/ folder. To get there, click on your desktop, open the Go menu, select Go to folder..., and type /Applications/Utilities/. Then run the Terminal program. +

    On Mac OS X, there is an application called Terminal in your /Applications/Utilities/ folder. To get there, click on your desktop, open the Go menu, select Go to folder..., and type /Applications/Utilities/. Then double-click the Terminal program. + +

    On Windows, click Start, select Run..., type cmd, and press ENTER. + +

    Running Python on the command line

    + +

    Once you get to the command line, you should be able to run the Python interactive shell. On the Linux or Mac OS X command line, type python3 and press ENTER. On the Windows command line, type c:\python31\python and press ENTER. If all goes well, you should see something like this: + +

    +you@localhost:~$ python3
    +Python 3.1 (r31:73572, Jul 28 2009, 06:52:23) 
    +[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
    +Type "help", "copyright", "credits" or "license" for more information.
    +>>>
    + +

    (Type exit() and press ENTER to exit the Python interactive shell and go back to the command line. This works on all platforms.) + +

    If you get a “command not found” error, it probably means you don’t have Python 3 installed. + +

    +you@localhost:~$ python3
    +bash: python3: command not found
    + +

    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. + +

    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 python3.0, python3.1, or python2.6. + +

    +mark@atlantis:~$ python3.0
    +Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52)
    +[GCC 4.3.3] on linux2
    +Type "help", "copyright", "credits" or "license" for more information.
    +>>> exit()
    +mark@atlantis:~$ python3.1
    +Python 3.1 (r31:73572, Jul 28 2009, 06:52:23) 
    +[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2
    +Type "help", "copyright", "credits" or "license" for more information.
    +>>> exit()
    +mark@atlantis:~$ python2.6
    +Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
    +[GCC 4.4.3] on linux2
    +Type "help", "copyright", "credits" or "license" for more information.
    +>>> exit()