Python双版本Windows安装攻略

本文将详细介绍如何在 windows 系统上安装 python 2.x 和 python 3.x,并说明如何配置环境变量。

一、Python 2.x 安装与配置

  1. 下载 Python 2.x 安装包

    下载地址:https://www.php.cn/link/598e989a5706e1ab5cea5e65598d2125

    进入页面后,选择对应版本进行下载:

    立即学习Python免费学习笔记(深入)”;

    Python双版本Windows安装攻略 alt=”Python双版本windows安装攻略” />Python2 下载页面

  2. 安装 Python 2.x

    下载完成后,启动安装包:

    Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />Python2 安装界面

    默认安装路径为 C:Python27,你也可以选择自定义路径(例如:D:Python27):

    Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />Python2 自定义路径

    后续步骤直接点击 Next 即可完成安装。

  3. 配置环境变量

    安装完成后,需要手动配置环境变量:

    • 打开环境变量设置窗口,新增一个系统变量,变量名为 PythonRoot,变量值为 Python 安装路径,如:D:Python27。

      Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />新建 PythonRoot 变量

    • 修改系统变量中的 Path,添加 %PythonRoot%:

      Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />修改 Path 变量

    • 同时还需添加 Python 的脚本工具目录,即在 PythonRoot 后面添加分号 ;,再追加 python安装目录Scripts,例如:

      D:Python27;D:Python27Scripts

      Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />添加 Scripts 目录

  4. 解决 Windows 商店弹出问题(可选)

    如果在命令提示符(cmd)中输入 python 后弹出 Windows 商店,可以通过修改 Python 安装目录下的 python.exe 名称来解决:

    例如,将 python.exe 重命名为 python2.exe:

    Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />修改 python.exe 名称

  5. 验证安装

    打开 cmd,输入修改后的名称(如 python2),出现 Python 版本信息即表示安装成功:

    python2

二、Python 3.x 安装与配置

Python 3.x 的安装相对简单,安装程序会自动添加环境变量。

  1. 下载 Python 3.x 安装包

    下载地址:https://www.php.cn/link/598e989a5706e1ab5cea5e65598d2125

    选择对应版本进行下载:

    Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />Python3 下载页面

  2. 安装 Python 3.x

    双击下载好的安装包,打开安装界面:

    • 勾选 Add Python 3.x to PATH 以自动添加环境变量。
    • 点击 Customize installation 可自定义安装路径(可选)。
    • 点击 Install Now 直接安装到默认路径。

    Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />Python3 安装界面

    后续步骤直接点击下一步即可完成安装。

  3. 验证安装

    同样,如果输入 python 命令后弹出 Windows 商店,可以将 Python 3.x 安装目录下的 python.exe 重命名为 python3.exe:

    打开 cmd,输入修改后的名称(如 python3),若出现 Python 版本信息,则表示安装成功:

    python3

    Python双版本Windows安装攻略 alt=”Python双版本Windows安装攻略” />验证 Python3 安装

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享