栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pip 升级python包

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pip 升级python包

pip 升级python包

Pip is a popular command used to manage Python packages.  Pip command is also used for updating/upgrading already installed Python packages.

Pip是用于管理Python软件包的常用命令。 Pip命令还用于更新/升级已经安装的Python软件包。

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

Before updating or upgrading an installed Python package we will list already installed packages. We will use the list command which will display the complete name and the version of the installed packages.

在更新或升级已安装的Python软件包之前,我们将列出已安装的软件包。 我们将使用list命令,该命令将显示已安装软件包的完整名称和版本。

$ pip list

$ pip2 list

$ pip3 list
List Installed Packages
列出已安装的软件包
检查是否安装了Python软件包(Check If A Python Package Is Installed)

In the previous example, we have just listed all installed packages and versions. We can also check if a specific python package is already installed. We will also use grep command by providing the name of the package we want to check.

在前面的示例中,我们刚刚列出了所有已安装的软件包和版本。 我们还可以检查是否已经安装了特定的python软件包。 我们还将通过提供要检查的软件包的名称来使用grep命令。

$ pip list | grep ufw
$ pip list | grep zipstream
$ pip list | grep django
$ pip list | grep xml
$ pip list | grep pip
Check If A Python Package Is Installed
检查是否安装了Python软件包
列出过时的Python软件包(List Outdated Python Packages)

Pip command also provides --outdated options with the list command which will list outdated and already installed python packages.

Pip命令还为list命令提供了--outdated选项,该命令将列出已过期和已安装的python软件包。

$ pip list --outdated

$ pip2 list --outdated

$ pip3 list --outdated
List Outdated Python Packages
列出过时的Python软件包
将Python软件包升级/更新到最新版本(Upgrade/Update Python Package To The Latest Version)

We will use the install command with the --upgrade option and also provide the package name. In this example, we will update/upgrade the package named Django to the latest version. We will also provide the --user option. Alternatively to the --upgrade we can use -U which is the short form.

我们将使用带有--upgrade选项的install命令,并提供软件包名称。 在此示例中,我们将把名为Django的软件包更新/升级到最新版本。 我们还将提供--user选项。 除了--upgrade我们还可以使用-U缩写。

$ pip install --user --upgrade django

$ pip2 install --user --upgrade django

$ pip3 install --user --upgrade django
Upgrade/Update Python Package To The Latest Version
将Python软件包升级/更新到最新版本

From the screenshot, we see that first the Django version 2.0 is found. Django version 2.0 is uninstalled and then Django version 2.2.5 is installed which will complete the upgrade/update of the Django.

从屏幕截图中,我们看到首先找到了Django 2.0版。 卸载Django 2.0版,然后安装Django 2.2.5版,这将完成Django的升级/更新。

LEARN MORE  How To Install and Use OpenSSL Library In Python Applications? 了解更多如何在Python应用程序中安装和使用OpenSSL库? 将Python软件包升级/更新到特定版本 (Upgrade/Update Python Package To The Specific Version)

In the previous example, we have updated the Django python package to the latest version. We can also update/upgrade a python package into a specific version which is not the latest. In this example, we will upgrade/update a specific version which is not the latest with the equal signs. We will not use the --upgrade option but specify the upgraded version.

在前面的示例中,我们已将Django python软件包更新为最新版本。 我们还可以将python软件包更新/升级到特定版本,而不是最新版本。 在此示例中,我们将升级/更新特定版本,该版本不是带有等号的最新版本。 我们将不使用--upgrade选项,而是指定升级版本。

$ pip install --user django==2.2

$ pip2 install --user django==2.2

$ pip3 install --user django==2.2
Upgrade/Update Python Package To The Specific Version
将Python软件包升级/更新到特定版本

We can see that the currently installed version is Django 2.0 but we will upgrade it into version 2.2 .

我们可以看到当前安装的版本是Django 2.0,但是我们将其升级到2.2版。

将Python软件包降级到特定版本 (Downgrade Python Package To The Specific Version)

We can also downgrade the installed package into a specific version. We will specify the Python package name with the version we want to downgrade by using equation signs like below. In this example, we will downgrade the Django package to version 2.0.

我们还可以将已安装的软件包降级为特定版本。 我们将使用以下等式符号来指定Python包名称以及要降级的版本。 在此示例中,我们将Django软件包降级为2.0版。

$ pip install --user django==2

$ pip2 install --user django==2

$ pip3 install --user django==2
Downgrade Python Package To The Specific Version
将Python软件包降级到特定版本

翻译自: https://www.poftut.com/how-to-update-upgrade-a-python-package-with-pip/

pip 升级python包

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/833663.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号