您当前位置:首页 > 深入 Python > 安装 Python > Mac OS X 上的 Python | << >> | ||||
深入 Python从 Python 新手到专家 |
在 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 >> |