什么是Python中的Pip?

Pip是Python的包管理器,用于安装、更新和卸载Python库。它与Python软件包索引PyPI配合使用,提供了一个庞大的软件包资源库。本文介绍了如何使用Pip进行搜索、安装、更新和列出Python包,以及如何获取包的详细信息。此外,还详细阐述了如何在不同操作系统上安装Pip。
摘要由CSDN通过智能技术生成

Pip is a command and tool used to manage Python libraries, modules, and packages. Python has a lot of packages because of its popularity and installation, updating and removing them can be done with the Pip package manager.

Pip是用于管理Python库,模块和包的命令和工具。 由于Python的普及和安装,Python有很多软件包,可以使用Pip软件包管理器来更新和删除它们。

Python包索引 (Python Package Index)

First, we have to learn about Python packages and repository. Python Package Index of PyPI is a repository that stores and serves Python packages. PyPI is created by the Python Software Foundation. Currently I provides 196,370 projects with 1,465,722 releases with 371,687 users.

首先,我们必须了解Python软件包和存储库。 PyPI的Python软件包索引是一个存储和提供Python软件包的存储库。 PyPI由Python软件基金会创建。 目前,我为196,370个项目提供了1,465,722个版本,拥有371,687个用户。

https://pypi.org

https://pypi.org

Python Package Index
Python Package Index
Python包索引

From PyPI, we can search or browse projects and packages. For example, when we search for Django we will see the following results. We will click to the Django 2.2.5 which is the official Django project.

通过PyPI,我们可以搜索或浏览项目和程序包。 例如,当我们搜索Django时,将看到以下结果。 我们将单击官方的Django项目Django 2.2.5

Python Package Index Search
Python Package Index Search
Python软件包索引搜索

We will be redirected to the following Django Pip Package page which provides information like installation, project description, release history, download files bug tracker, source code, funding, and documentation.

我们将被重定向到下面的Django Pip Package页面,该页面提供诸如安装,项目描述,发行历史,下载文件,错误跟踪器,源代码,资金和文档之类的信息。

https://pypi.org/project/Django/

https://pypi.org/project/Django/

Python Package Index Package Details
Python Package Index Package Details
Python软件包索引软件包详细信息

安装点(Installing Pip)

As Python is a cross-platform scripting/programming language also the package manager Pip is cross-platform too. We can install Pip for operating systems like Windows, Linux, Ubuntu, Fedora, Ubuntu, CentOS, Kali, Mint, MacOSX, RaspberryPi, etc where Python interpreter works. Below you can find how to install Pip for different operating systems and platforms.

由于Python是一种跨平台的脚本/编程语言,因此程序包管理器Pip也是跨平台的。 我们可以为Windows解释器可在Windows,Linux,Ubuntu,Fedora,Ubuntu,CentOS,Kali,Mint,MacOSX,RaspberryPi等操作系统上安装Pip。 您可以在下面找到如何为不同的操作系统和平台安装Pip。

How To Install Python Pip For Linux?

如何为Linux安装Python Pip?

点用法和命令 (Pip Usage and Commands)

In this part, we will learn basic usage of Pip and its commands. Pip provides commands to search, install, update, list, etc. packages.

在这一部分中,我们将学习Pip及其命令的基本用法。 Pip提供了用于搜索,安装,更新,列出等软件包的命令。

点帮助和列表命令 (Pip Help and List Commands)

We can use the -h option in order to list simple help information about the pip command like below. Also, general options will be listed.

我们可以使用-h选项来列出有关pip命令的简单帮助信息,如下所示。 另外,将列出常规选项。

$ pip -h
Pip Help and List Commands
Pip Help and List Commands
点帮助和列表命令

For more detailed help man command can be used. This will list all available commands and options about the pip.

要获得更详细的帮助,可以使用man命令。 这将列出有关点的所有可用命令和选项。

$ man pip
Pip Help and List Commands
Pip Help and List Commands
点帮助和列表命令

搜索Python包(Search Python Package)

We can use the search command and provide the term or package name we want to search. In this example, we will search the package named django.

我们可以使用search命令并提供我们要搜索的术语或软件包名称。 在此示例中,我们将搜索名为django的软件包。

$ pip3 search django
Search Python Package
Search Python Package
搜索Python包

显示Python软件包信息(Show Python Package Information)

We can show the package information with the pip command by using showcommand and providing the package name we want to show information. In this example, we will show information about the Django package.

我们可以使用show命令并通过pip命令显示软件包信息,并提供要显示信息的软件包名称。 在此示例中,我们将显示有关Django软件包的信息。

$ pip3 show django
Show Python Package Information
Show Python Package Information
显示Python软件包信息

安装Python包(Install Python Package)

We can install a package by using the install pip command. We will also provide the package complete name. In this example, we will install the package named Django. During the installation, the main package and its dependencies will be downloaded and extracted required fields.

我们可以使用install pip命令安装软件包。 我们还将提供包裹的全名。 在此示例中,我们将安装名为Django的软件包。 在安装过程中,将下载主软件包及其依赖项并提取必填字段。

$ pip3 install django
Install Python Package
Install Python Package
安装Python包

更新Python包(Update Python Package)

Popular python packages are updated regularly.  We can update the already installed package with the install --upgrade command of the pip. We will also provide the package named django in this example.

流行的python软件包会定期更新。 我们可以使用pip的install --upgrade命令更新已经安装的软件包。 在此示例中,我们还将提供名为django的软件包。

$ pip3 install --upgrade django
Update Python Package
Update Python Package
更新Python包

列出已安装的Python软件包(List Installed Python Packages)

We can also list already installed packages. We will use list pip command like below.

我们还可以列出已经安装的软件包。 我们将使用list pip命令,如下所示。

$ pip3 list
List Installed Python Packages
List Installed Python Packages
列出已安装的Python软件包
LEARN MORE  How To Uninstall A Package with Pip?
了解更多如何使用Pip卸载软件包?

翻译自: https://www.poftut.com/what-is-pip-in-python/

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值