Python学习之pip指令的使用

pip 是一个现代的,通用的Python包管理工具。提供了对 Python 包的查找、下载、安装、卸载的功能,便于我们对Python的资源包进行管理

1.安装

在安装Python时会自动下载并且安装pip。

2.配置

  • 在windows命令行中,输入pip -v 可以查看pip的版本

image.png

  • 在输入命令pip -v 后,如果出现了如下图的提示

在这里插入图片描述

可能是因为在安装python的过程中未勾选 Add Python 3.7 to Path 选项,需要手动的配置pip的环境变量。

  • 右键 此电脑 -> 环境变量 -> 找到并双击 Path ->在弹窗里点击新建 -> 找到 pip 的安装目录,把路径添加进去

在这里插入图片描述

  • 这里新添加的路径 E:\python\Scripts 是Python安装好以后, pip.exe 这个可执行文件所在的目录

3.使用pip管理Python包(联想Java构建项目的步骤来对比)

3.1指令说明

install                     Install packages.
download                    Download packages.
uninstall                   Uninstall packages.
freeze                      Output installed packages in requirements format.
list                        List installed packages.
show                        Show information about installed packages.
check                       Verify installed packages have compatible dependencies.
config                      Manage local and global configuration.
search                      Search PyPI for packages.
cache                       Inspect and manage pip's wheel cache.
index                       Inspect information available from package indexes.
wheel                       Build wheels from your requirements.
hash                        Compute hashes of package archives.
completion                  A helper command used for command completion.
debug                       Show information useful for debugging.
help                        Show help for commands.

注意:最好默认将下载的包都丢放在自己安装Python的目录下的Scripts中,如 E:\python\Scripts

3.2修改pip下载源

运行pip install 命令会从网站上下载指定的python包,默认是从 https://files.pythonhosted.org/ 网站上下载。这是个国外的网站,遇到网络情况不好的时候,可能会下载失败,我们可以通过命令,修改pip现在软件时的源。格式:

pip install 包名 -i 国内源地址
# 常用的国内的pip源下载列表
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
# 示例
pip install ipython -i http://mirrors.aliyun.com/pypi/simple/
pip install ipython -i https://pypi.mirrors.ustc.edu.cn/simple/
pip install ipython -i http://pypi.douban.com/simple/
pip install ipython -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install ipython -i https://pypi.mirrors.ustc.edu.cn/simple/
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

five-five

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

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

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

打赏作者

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

抵扣说明:

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

余额充值