Python学习笔记一 ,环境搭建。

## 1.WIndwos上的Python ##

第二种选择是使用由 Python 发布的 “官方” Python 安装程序。她是可自由下载的 开源软件, 并且您总是可以获得当前 Python 的最新版本。

过程 1.1. 选项 1: 安装 ActivePython
下面描述 ActivePython 的安装过程:

http://www.activestate.com/Products/ActivePython/ 下载 ActivePython 。

如果您正在使用 Windows 95, Windows 98 或 Windows ME, 还需要在安装 ActivePython 之前下载并安装Windows Installer 2.0 。

双击安装程序 ActivePython-2.2.2-224-win32-ix86.msi。

按照安装程序的提示信息一步步地执行。

如果磁盘空间不足, 您可以执行一个定制安装, 不选文档, 但是笔者不建议您这样做, 除非您实在是挤不出14M空间来。

在安装完后之后, 关闭安装程序, 打开 Start->Programs->ActiveState ActivePython 2.2->PythonWin IDE。 您将看到类似如下的信息:

PythonWin 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) -
see 'Help/About PythonWin' for further copyright information.
>>> 

过程 1.2. 选项 2: 安装来自 Python.org 的 Python
http://www.python.org/ftp/python/选择最新的 Python Windows 安装程序, 下载 .exe 安装文件。

双击安装程序 Python-2.xxx.yyy.exe。 文件名依赖于您所下载的 Python 安装程序文件。

按照安装程序的提示信息一步步地执行。

如果磁盘空间不足, 可以取消 HTMLHelp 文件, 实用脚本 (Tools/), 和/或 测试套件 (Lib/test/)。

如果您没有机器的管理员权限, 您可以选择, Advanced Options, 然后选择 Non-Admin Install。 这只对登记注册表和开始菜单中创建的快捷方式有影响。

在安装完成之后, 关闭安装程序, 打开 Start->Programs->Python 2.3->IDLE (Python GUI)。 您将看到类似如下的信息:

Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.0
>>> 

2.Mac OS X上的Python

在 Mac OS X 上, 对于安装 Python 有两种选择: 安装或不安装。您可能想要安装它。

Mac OS X 10.2 及其后续版本已经预装了一个 Python 的命令行版本。 如果您习惯使用命令行, 那么您可以使用它学完本书的三分之一。然而, 预安装的版本不带 XML 解析器, 所以当您学到 XML 的章节时, 您会需要安装完整版。

您还可以安装优于预装版本的最新的包含图形界面 Shell 的完整版本。

过程 1.3. 在 Mac OS X 上运行预装版本的 Python
使用预装的 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% 

过程 1.4. 在 Mac OS X 上安装最新版的 Python
下面介绍下载并安装 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没有出现, 选择 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% 

3.Debian GNU/Linux 上的 Python

如果您碰巧运行在 Debian GNU/Linux 上, 安装 Python 需要使用 apt 命令。

例 1.3. 在 Debian GNU/Linux 上安装

localhost:~$ su -
Password: [enter your root password]
localhost:~# apt-get install python
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  python2.3
Suggested packages:
  python-tk python2.3-doc
The following NEW packages will be installed:
  python python2.3
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 0B/2880kB of archives.
After unpacking 9351kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Selecting previously deselected package python2.3.
(Reading database ... 22848 files and directories currently installed.)
Unpacking python2.3 (from .../python2.3_2.3.1-1_i386.deb) ...
Selecting previously deselected package python.
Unpacking python (from .../python_2.3.1-1_all.deb) ...
Setting up python (2.3.1-1) ...
Setting up python2.3 (2.3.1-1) ...
Compiling python modules in /usr/lib/python2.3 ...
Compiling optimized python modules in /usr/lib/python2.3 ...
localhost:~# exit
logout
localhost:~$ python
Python 2.3.1 (#2, Sep 24 2003, 11:39:14)
[GCC 3.3.2 20030908 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

 [press Ctrl+D to exit]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值