python pip命令_如何通过示例使用Python Pip命令和教程?

python pip命令

python pip命令

Pip is the package manager for Python programming language and framework. Python uses packages and modules in order to provide libraries and functions. These packages provided by the Python Package Index or PyPI. PyPI is called a repository index for Python software. PyPI helps us to find and install software developed and shared by the Python community.

Pip是Python编程语言和框架的软件包管理器。 Python使用软件包和模块来提供库和函数。 这些软件包由Python Package Index或PyPI提供。 PyPI被称为Python软件的存储库索引。 PyPI帮助我们查找和安装由Python社区开发和共享的软件。

Python包 (Python Package)

Python is a very simple programming language where its package or module structure is simple too. Python package contains related modules, py files, functions, classes we want to use.

Python是一种非常简单的编程语言,其包或模块结构也很简单。 Python软件包包含我们要使用的相关模块, py文件,函数,类。

检查是否安装了Pip (Check If Pip Is Installed)

We will start by checking whether the pip is installed. In some cases, pip may be installed by default. By the way, there is two pip version which is related to the Python main versions Python2 and Python3.  We will use pip , pip2 and pip3 commands where pip is generally related to the pip2. We will provide the -V or --version options like below.

我们将从检查是否已安装pip开始。 在某些情况下,默认情况下可能会安装pip。 顺便说一下,有两个pip版本与Python主要版本Python2和Python3有关。 我们将使用pippip2pip3命令,其中pip通常与pip2 。 我们将提供如下所示的-V--version选项。

$ pip -V
$ pip --version

OR

要么

$ pip3 -V
$ pip3 --version

OR

要么

$ pip2 -V
$ pip2 --version
Check If Pip Is Installed
Check If Pip Is Installed
检查是否安装了Pip

We can see that both versions of the pip like pip2 and pip3 are installed in the given example.

我们可以看到在给定的示例中同时安装了两个版本的pip,例如pip2和pip3。

为Python2和Python3安装Pip (Install Pip For Python2 and Python3)

If the pip is not installed we can install it to the Linux, Ubuntu, Mint, Kali easily. We can install it for apt based distributions like Ubuntu, Debian, Mint, Kali, like below.

如果未安装pip,我们可以轻松地将其安装到Linux,Ubuntu,Mint和Kali。 我们可以将其安装在基于apt的发行版中,例如Ubuntu,Debian,Mint,Kali,如下所示。

$ sudo apt install python2-pip
Install Pip For Python2 and Python3
Install Pip For Python2 and Python3
为Python2和Python3安装Pip

OR for Python3

或适用于Python3

$ sudo apt install python3-pip
Install Pip For Python2 and Python3
Install Pip For Python2 and Python3
为Python2和Python3安装Pip

We can install for yum based distributions like Fedora, CentOS, RedHat like below.

我们可以为基于yum的发行版(如Fedora,CentOS,RedHat)进行安装,如下所示。

$ sudo yum install python2-pip
Install Pip For Python2 and Python3
Install Pip For Python2 and Python3
为Python2和Python3安装Pip

OR for Python3

或适用于Python3

$ sudo yum install python3-pip
Install Pip For Python2 and Python3
Install Pip For Python2 and Python3
为Python2和Python3安装Pip

More detailed about installing Python can be found in the following link.

可以在以下链接中找到有关安装Python的更多详细信息。

LEARN MORE  HTTP 403 Forbidden Status Code and Fix Error
了解更多HTTP 403禁止状态代码和修复错误

How To Install Python Pip For Linux?

如何为Linux安装Python Pip?

打印帮助信息 (Print Help Information)

Pip command has very simple usage and provides a dozen commands and options. We can list help information and these command with the pip help command like below. This will also provide some short description of the command. We will examine most of the and usage in this tutorial.

Pip命令用法非常简单,并提供了十二个命令和选项。 我们可以使用如下pip help命令列出帮助信息和这些命令。 这还将提供该命令的一些简短说明。 我们将在本教程中研究的大多数用法。

$ pip help
Print Help Information
Print Help Information
打印帮助信息

From the output, we can see that help information about the following commands is provided.

从输出中,我们可以看到提供了有关以下命令的帮助信息。

  • install

    安装
  • download

    下载
  • uninstall

    卸载
  • freeze

    冻结
  • list

    清单
  • show

    显示
  • check

    检查
  • search

    搜索
  • wheel

  • hash

    杂凑
  • completion

    完成
  • help

    帮帮我

用点搜索包(Search Package with Pip)

We will start with the search operation where we will provide some search term related to the package we want to find. We will use search pip command. In this example, we will search the package named scrapy

我们将从搜索操作开始,在该操作中,我们将提供一些与要查找的软件包相关的搜索词。 我们将使用search pip命令。 在此示例中,我们将搜索名为scrapy的软件包

$ pip3 search scrapy
Search Package with Pip
Search Package with Pip
用点搜索包

We can see from the output that there are a lot of packages with the name of the scrapy

从输出中我们可以看到有很多名为scrapy

用Pip列出已安装的软件包 (List Installed Packages with Pip)

Pip is a complete package manager where we can list already installed packages with the list command. As you gues we will not provide any extra option the list command.

Pip是一个完整的软件包管理器,在这里我们可以使用list命令列出已安装的软件包。 如您所想,我们将不再提供list命令的任何其他选项。

$ pip3 list
List Installed Packages with Pip
List Installed Packages with Pip
用Pip列出已安装的软件包

We can see that packages like Django, pycairo etc. are all ready installed to the current pip3 package manager.

我们可以看到像Djangopycairo等之类的软件包都已准备好安装到当前的pip3软件包管理器中。

用Pip安装软件包 (Install Package with Pip)

After searching the package and finding the full and complete package name we can install it with the install command. But keep in mind that PyPI or pip provides a lot of packages for the same context and with similar names. So we have to provide the complete and precise name of the package. In this example, we will install the package named gns3-server .

搜索软件包并找到完整的软件包名称后,我们可以使用install命令进行install 。 但是请记住,PyPI或pip为相同的上下文和相似的名称提供了很多软件包。 因此,我们必须提供软件包的完整且准确的名称。 在此示例中,我们将安装名为gns3-server的软件包。

$ pip3 install gns3
Install Package with Pip
Install Package with Pip
用Pip安装软件包

通过Pip显示Python软件包信息(Show Python Package Information with  Pip)

Each python package has attributes or meta-data like name, version, license etc. We can print this information with the show command and providing the package name. In this example, we will print  gns3-server package information like below.

每个python软件包都有属性或元数据,例如名称,版本,许可证等。我们可以使用show命令打印此信息并提供软件包名称。 在此示例中,我们将打印gns3-server软件包信息,如下所示。

$ pip3 show gns3-server
Show Python Package Information with  Pip
Show Python Package Information with  Pip
通过Pip显示Python软件包信息

We see that following information about the given Python package is provided.

我们看到提供了有关给定Python包的以下信息。

  • `Name` is the official pip name of the package where `gns3-server` is in this example

    “名称”是软件包的正式点名称,在此示例中,“ gns3-server”位于其中
  • `Version` is the package pip version which is recent. In this example `2.1.16` is the recent version of the package gns3-server

    Version是最新的软件包pip版本。 在此示例中,“ 2.1.16”是软件包gns3-server的最新版本。
  • `Summary` is a short description which explains package. gns3-server package description is `GNS3 Server` in this example

    “摘要”是对软件包的简短说明。 在此示例中,gns3-server软件包描述为“ GNS3 Server”
  • `Home-page` is the package upstream or creator home page which is `http://github.com/GNS3/gns3-server` in this case

    “首页”是程序包的上游或创建者主页,在本例中为“ http://github.com/GNS3/gns3-server”
  • `Author` is the creator of this package python code which is unknown in this example

    “作者”是此包python代码的创建者,在此示例中未知
  • `Author-email` is the creator email which is unknown in this example

    “作者电子邮件”是创建者电子邮件,在此示例中未知
  • `License` is the legal license of the given package which is `GPLv3` in this example

    “许可证”是给定软件包的合法许可证,在此示例中为“ GPLv3”
  • `Location` is the package path of modules, code and Python code which is `/home/ismail/.local/lib/python3.6/site-packages` in this example. `/home/ismail` is the user who is installed this package

    位置是模块,代码和Python代码的包路径,在此示例中为/home/ismail/.local/lib/python3.6/site-packages。 / home / ismail是安装此软件包的用户
  • `Requires` list the dependencies of this packages where `aiohttp`, `aiohttp-cors`, … is required in order to install and run `gns3-server` Python package

    `Requires`列出了此软件包的依赖关系,其中需要安装`aiohttp`,`aiohttp-cors`…才能安装和运行`gns3-server` Python软件包
LEARN MORE  How To Install Pip In Windows?
了解更多如何在Windows中安装Pip?

使用Pip卸载或删除软件包 (Uninstall or Remove Package with Pip)

If we do not need the package we can uninstall or remove the package with the uninstall command like below. We will uninstall the package named gns3-server.

如果我们不需要该软件包,则可以使用如下所示的uninstall命令来卸载或删除该软件包。 我们将卸载名为gns3-server的软件包。

$ pip3 uninstall gns3-server
Uninstall or Remove Package with Pip
Uninstall or Remove Package with Pip
使用Pip卸载或删除软件包

We can see that all files under the /home/ismail/.local/lib/python3.6/site-packages/gns3server/ is deleted and verbosely shown as output for the uninstall command.

我们可以看到/home/ismail/.local/lib/python3.6/site-packages/gns3server/下的所有文件/home/ismail/.local/lib/python3.6/site-packages/gns3server/被删除,并作为卸载命令的输出详细显示。

仅下载软件包不安装 (Only Download Package Do Not Install)

If we want to only get some part of the package and do not want to install to the system we can use download command which will download the package to the current working path. The downloaded file will be compressed and in tar.gz format with the package name and version. In this example, we will download the package named gns3-server.

如果我们只想获取软件包的一部分,并且不想安装到系统中,则可以使用download命令将软件包下载到当前工作路径。 下载的文件将被压缩,并以tar.gz格式包含包名称和版本。 在此示例中,我们将下载名为gns3-server的软件包。

Only Download Package Do Not Install
Only Download Package Do Not Install
仅下载软件包不安装

The downloaded file will be named as gns3-server-2.1.16.tar.gz.

下载的文件将被命名为gns3-server-2.1.16.tar.gz

翻译自: https://www.poftut.com/how-to-use-python-pip-command-and-tutorial-with-examples/

python pip命令

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值