| 導航:起始頁 > Dive Into Python > 安裝 Python > Mac OS X 上的 Python | << >> | ||||
深入 Python :Dive Into Python 中文版Python 從新手到專家 [Dip_5.4b_CPyUG_Release] |
|||||
在 Mac OS X 上,對于安裝 Python 有兩種選擇:安裝或不安裝。您可能想要安裝它。
Mac OS X 10.2 及其后續版本已經預裝了一個 Python 的命令行版本。如果您習慣使用命令行,那么您可以使用它學完本書的三分之一。然而,預安裝的版本不帶 XML 解析器,所以當您學到 XML 的章節時,您會需要安裝完整版。
您還可以安裝優于預裝版本的最新的包含圖形界面 Shell 的完整版本。
使用預裝的 Python 版本的步驟:
打開 /Applications 文件夾。
打開 Utilities 文件夾。
雙擊 Terminal 打開一個終端進入命令行窗口。
在提示符下鍵入 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%
下面介紹下載并安裝 Python 最新版本的過程:
從 http://homepages.cwi.nl/~jack/macpython/download.html 下載 MacPython-OSX 磁盤鏡像 。
下載完畢,雙擊 MacPython-OSX-2.3-1.dmg 將磁盤鏡像掛載到桌面。
雙擊安裝程序 MacPython-OSX.pkg.
安裝程序將提示要求您的管理員用戶名和口令。
按照安裝程序的提示一步步執行。
安裝完畢后,關閉安裝程序,打開 /Applications 文件夾。
打開 MacPython-2.3 文件夾。
雙擊 PythonIDE 來運行 Python 。
MacPython IDE 將顯示啟動畫面將您帶進交互 shell。如果交互 shell 沒有出現,選擇 -> (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 。
[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%
<< Windows 上的 Python |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
Mac OS 9 上的 Python >> |