Python - Windows下安装pip

当你使用 [ python.org]( https://www.python.org) 的官方安装程序安装 Python 时,它通常会将 `pip` 作为安装过程的一部分。以下是你需要了解的内容:
When you install Python using the official installer from [ python.org]( https://www.python.org), it typically includes `pip` as part of the installation process. Here's what you need to know:
1. Check if `pip` is Installed
安装 Python 后,可以通过打开命令提示符并运行来验证是否安装了 `pip`:
After installing Python, you can verify if `pip` is installed by opening the Command Prompt and running:
pip --version
如果安装了 `pip`,此命令将显示已安装的 `pip` 版本。如果没有,则会显示错误信息。
If `pip` is installed, this command will show the installed version of `pip`. If not, it will give you an error message.
2. Install `pip` Manually
如果未包含或缺少 `pip`,可按照以下步骤手动安装:
If `pip` was not included or is missing, you can install it manually by following these steps:
2.1 Download `get-pip.py`:
- 下载 `get-pip.py` 脚本,请访问: https://bootstrap.pypa.io/get-pip.py
- 将脚本保存到电脑中。
- Download the `get-pip.py` script by visiting: https://bootstrap.pypa.io/get-pip.py
- Save the script to your computer.
2.2 Run the Script:
打开下载脚本的命令提示符并运行以下命令:
Open a Command Prompt where you downloaded the script and run the following command:
python get-pip.py
这将在系统中安装 `pip`。
This will install `pip` on your system.
2.3 Add Python and `pip` to PATH
在 Windows 上安装 Python 的过程中,请务必选中 “将 Python 添加到 PATH ”复选框。如果忘记这样做,“命令提示符 ”中的 `pip` 可能无法直接运行。你可以按照以下步骤手动将 Python 和 `pip` 添加到 PATH:
1. 打开 “开始 ”菜单,搜索 “环境变量”,然后点击 “编辑系统环境变量”。
2. 在打开的对话框中,单击环境变量。
3. 3. 在 “系统变量 ”部分,向下滚动并找到 “路径”,然后单击 “编辑”。
4. 单击 “新建 ”并添加 Python 安装路径(例如,“C:\Python39 ”或 “C:\Users\YourUsername\AppData\Local\Programs\Python\Python39\”)。
5. 同时添加 `pip` 所在的 `Scripts` 目录的路径(例如,`C:\Users\YourUsername\AppData\Local\Programs\Python\Python39\Scripts\` )。
6. 单击 “确定 ”关闭所有对话框,然后重启命令提示符使更改生效。
During the Python installation process on Windows, make sure to check the box that says "Add Python to PATH". If you forget to do this, `pip` might not work directly from the Command Prompt. You can manually add Python and `pip` to your PATH by following these steps:
1. Open the Start menu, search for Environment Variables, and click on Edit the system environment variables.
2. In the dialog that opens, click on Environment Variables.
3. In the System Variables section, scroll down and find Path, then click Edit.
4. Click New and add the path to your Python installation (e.g., `C:\Python39` or `C:\Users\YourUsername\AppData\Local\Programs\Python\Python39\`).
5. Also add the path to the `Scripts` directory, where `pip` is located (e.g., `C:\Users\YourUsername\AppData\Local\Programs\Python\Python39\Scripts\`).
6. Click OK to close all dialogs, then restart your Command Prompt for changes to take effect.
3. Using `python -m pip`
如果将 `pip` 添加到 PATH 后,直接运行 `pip` 仍然不起作用,可以使用此替代命令:
If running `pip` directly doesn't work even after adding it to the PATH, you can use this alternative command:
python -m pip install package_name
这会告诉 Python 将 `pip` 作为一个模块运行。
This tells Python to run `pip` as a module.
4, 升级pip
python -m pip3 install -U pip    # python3.x
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值