当前位置: 首页 > article >正文

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

http://www.kler.cn/news/343023.html

相关文章:

  • 【含开题报告+文档+PPT+源码】基于过滤协同算法的旅游推荐管理系统设计与实现
  • 408算法题leetcode--第30天
  • 97. UE5 GAS RPG 实现闪电链技能(二)
  • 项目常用版本控制管理工具
  • Nacos 2.2.x版本配置详解(鉴权版本)
  • 【VUE】Vue3中的diff流程
  • No.10 笔记 | PHP学习指南:PHP数组掌握
  • Linux的环境与历史
  • Label Studio 半自动化标注
  • 2-119 基于matlab的合成孔径雷达(SAR)RDA(距离多普勒算法)、RMA(距离徙动算法)、CSA(线性调频变标算法)算法点目标成像与分析
  • 搭建一个高效的 TikTok 节点:从零开始的实践指南
  • 10月10日
  • ECharts 实例对象中的所有选项配置详解
  • 前端reactvue3——实现滚动到底加载数据
  • 高级java每日一道面试题-2024年10月7日-框架篇[springboot篇]-springboot如何处理循环依赖的问题?
  • VVIC商品详情接口技术解析与实战代码示例
  • 数据结构——顺序表的实现
  • merlion的dashboard打开方法
  • 微服务之间的相互调用的几种常见实现方式对比
  • Qt实现侧边栏功能