<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            1.3. Mac OS X 上的 Python

            Mac OS X 上,對于安裝 Python 有兩種選擇:安裝或不安裝。您可能想要安裝它。

            Mac OS X 10.2 及其后續版本已經預裝了一個 Python 的命令行版本。如果您習慣使用命令行,那么您可以使用它學完本書的三分之一。然而,預安裝的版本不帶 XML 解析器,所以當您學到 XML 的章節時,您會需要安裝完整版。

            您還可以安裝優于預裝版本的最新的包含圖形界面 Shell 的完整版本。

            過程 1.3. 在 Mac OS X 上運行預裝版本的 Python

            使用預裝的 Python 版本的步驟:

            1. 打開 /Applications 文件夾。

            2. 打開 Utilities 文件夾。

            3. 雙擊 Terminal 打開一個終端進入命令行窗口。

            4. 在提示符下鍵入 python

            試驗:

            Welcome to Darwin!
            [localhost:~] you% python
            Python 2.2 (#1, 07/14/02, 23:25:09)
            [GCC Apple cpp-precomp 6.14] on darwin
            Type "help", "copyright", "credits", or "license" for more information.
            >>> [press Ctrl+D to get back to the command prompt]
            [localhost:~] you% 
            

            過程 1.4. 在 Mac OS X 上安裝最新版的 Python

            下面介紹下載并安裝 Python 最新版本的過程:

            1. http://homepages.cwi.nl/~jack/macpython/download.html 下載 MacPython-OSX 磁盤鏡像 。

            2. 下載完畢,雙擊 MacPython-OSX-2.3-1.dmg 將磁盤鏡像掛載到桌面。

            3. 雙擊安裝程序 MacPython-OSX.pkg.

            4. 安裝程序將提示要求您的管理員用戶名和口令。

            5. 按照安裝程序的提示一步步執行。

            6. 安裝完畢后,關閉安裝程序,打開 /Applications 文件夾。

            7. 打開 MacPython-2.3 文件夾。

            8. 雙擊 PythonIDE 來運行 Python

            MacPython IDE 將顯示啟動畫面將您帶進交互 shell。如果交互 shell 沒有出現,選擇 Window->Python Interactive (Cmd-0)。您將看到類似如下的信息:

            Python 2.3 (#2, Jul 30 2003, 11:45:28)
            [GCC 3.1 20020420 (prerelease)]
            Type "copyright", "credits" or "license" for more information.
            MacPython IDE 1.0.1
            >>> 
            

            請注意,安裝完最新版本后,預裝版本仍然存在。如果您從命令行運行腳本,那您需要知道正在使用的是哪一個版本的 Python

            例 1.1. 兩個 Python 版本

            [localhost:~] you% python
            Python 2.2 (#1, 07/14/02, 23:25:09)
            [GCC Apple cpp-precomp 6.14] on darwin
            Type "help", "copyright", "credits", or "license" for more information.
            >>> [press Ctrl+D to get back to the command prompt]
            [localhost:~] you% /usr/local/bin/python
            Python 2.3 (#2, Jul 30 2003, 11:45:28)
            [GCC 3.1 20020420 (prerelease)] on darwin
            Type "help", "copyright", "credits", or "license" for more information.
            >>> [press Ctrl+D to get back to the command prompt]
            [localhost:~] you% 
            
            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      亚洲欧美在线