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个用户。
![Python Package Index](https://i-blog.csdnimg.cn/blog_migrate/a5767bb2c816bd334558552e31854fba.png)
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](https://i-blog.csdnimg.cn/blog_migrate/25a24b9948ca79bd60cf5858c4b59b99.png)
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](https://i-blog.csdnimg.cn/blog_migrate/01e3b00b72dba9a0f1362f8e634b8be4.png)
安装点(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?
点用法和命令 (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](https://i-blog.csdnimg.cn/blog_migrate/c0b4bacd6459e7f05d62a010b0bf9511.png)
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](https://i-blog.csdnimg.cn/blog_migrate/b77e0304012be9fef94a3c7f9512cd0c.png)
搜索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](https://i-blog.csdnimg.cn/blog_migrate/4688298e97961fff7cb7e323b10e8754.png)
显示Python软件包信息(Show Python Package Information)
We can show the package information with the pip command by using show
command 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](https://i-blog.csdnimg.cn/blog_migrate/2579280cb2a9ad5205289d2ee3862243.png)
安装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](https://i-blog.csdnimg.cn/blog_migrate/838a51145481c8a7a4f2a8e3961c62b4.png)
更新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](https://i-blog.csdnimg.cn/blog_migrate/e70522981bd580de26df9cec1f866a00.png)
列出已安装的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](https://i-blog.csdnimg.cn/blog_migrate/126bbc9895e062fb3642bdee49ef37e0.png)