python中pip使用

  1. 检查当前pip版本
    在cmd下输入

pip --version

可显示当前pip库版本

  1. 安装第三方库

pip install 库名称(如requests)

安装第三方库

pip install reportlab==4.0.7

安装指定版本的reportlab

  1. 显示第三方库基本信息

pip show reports

Name: reportlab
Version: 4.0.7
Summary: The Reportlab Toolkit
Home-page: https://www.reportlab.com/
Author: Andy Robinson, Robin Becker, the ReportLab team and the community
Author-email: reportlab-users@lists2.reportlab.com
License: BSD license (see license.txt for details), Copyright (c) 2000-2022, ReportLab Inc.
Location: e:\program files\python\lib\site-packages
Requires: pillow
Required-by:
  1. 列出所有过时的库

pip list -o
pip list --outdated

pip list -o
Package    Version Latest Type
---------- ------- ------ -----
pypdf      3.8.1   3.17.1 wheel
setuptools 65.5.0  69.0.2 wheel

pip list --outdated
Package    Version Latest Type
---------- ------- ------ -----
pypdf      3.8.1   3.17.1 wheel
setuptools 65.5.0  69.0.2 wheel
  1. 将库升级到最新版本

pip install -U pip requests

更新requests库,若未安装request库,该命令会安装request库

  1. 更改安装库的源
    国内从Pypi安装库会很慢,可以更改安装库的源,提高下载速度(以更改为清华大学的源为例)

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

配置全局索引URL
要永久使用镜像站点安装库,不必每次安装时都键入url,可使用config选项全局设置url。以更改为清华大学站点为例:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

(1) 清华大学(完全度和速度都很好,是一个优秀的pip镜像源)

https://pypi.tuna.tsinghua.edu.cn/simple

(2)阿里云(完全度和速度也很好,是一个不错的选择)

https://mirrors.aliyun.com/pypi/simple/

(3)网易(速度比较快,但是完全度有限)

https://mirrors.163.com/pypi/simple/

(4)豆瓣(速度较快,但是完全度也有限)

https://pypi.douban.com/simple/

(5)百度云(速度较快,但是完全度也有限)

https://mirror.baidu.com/pypi/simple/

(6)中科大(速度较快,但完全度不如前面几个镜像源)

https://pypi.mirrors.ustc.edu.cn/simple/

(7)华为云(完全度和速度均中等)

https://mirrors.huaweicloud.com/repository/pypi/simple/

(8)腾讯云(速度一般,完全度也一般)

https://mirrors.cloud.tencent.com/pypi/simple/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值