Python Pip command provides search, install, update, uninstall packages. We can use pip command to uninstall packages easily even there are some alternatives like easy_install.
Python Pip命令提供搜索,安装,更新,卸载软件包。 即使有easy_install之类的替代方法,我们也可以使用pip命令轻松卸载软件包。
用Pip列出已经安装的Python软件包 (List Already Installed Python Packages with Pip)
Before uninstalling or removing Python packages with pip we will list already installed Python packages. We will use list
command for pip like below.
在通过pip卸载或删除Python软件包之前,我们将列出已安装的Python软件包。 我们将如下所示对pip使用list
命令。
$ pip list
We can see that the following information is provided by listing installed packages.
通过列出已安装的软件包,我们可以看到以下信息。
- `Package` column shows the package complete name
“包裹”列显示包裹的完整名称
- `Version` column shows the most recent version of the given package
“版本”列显示了给定软件包的最新版本
列出/显示Python软件包信息,版本(List/Display Python Packages Information, Version)
We can also show a given package complete information with the show
command which can be useful before uninstalling it. In this example, we will show information about the Python package named Django.
我们还可以使用show
命令显示给定的软件包完整信息,这在卸载之前可能很有用。 在此示例中,我们将显示有关名为Django的Python软件包的信息。
$ pip show django
使用Pip,Pip2,Pip3卸载/删除Python软件包(Uninstall/Remove Python Package with Pip, Pip2, Pip3)
We can uninstall the package with the uninstall
pip command. We will also provide the package name. In this example, we will uninstall the package named django
.
我们可以使用uninstall
pip命令来卸载软件包。 我们还将提供包裹名称。 在此示例中,我们将卸载名为django
的软件包。
$ pip uninstall django
We can see that the directories and files removed are listed and a confirmation is shown where we will input y
in order to accept the removal. After the remove/uninstall completed we will be shown Successfully uninstalled Django-2.2.5
我们可以看到列出了删除的目录和文件,并显示了一个确认,我们将在其中输入y
以接受删除。 删除/卸载完成后,我们将显示Successfully uninstalled Django-2.2.5
If we want to remove packages related to the Python2 we can use the same command for the pip2
command like below.
如果我们想删除与Python2相关的软件包,我们可以对pip2
命令使用相同的命令,如下所示。
$ pip2 uninstall django
If we want to remove packages related to the Python3 we can use the same command for the pip3
command like below.
如果我们想删除与Python3相关的软件包,我们可以对pip3
命令使用相同的命令,如下所示。
$ pip3 uninstall django
使用Pip卸载/删除具有要求的Python软件包 (Uninstall/Remove Python Package with Requirements with Pip)
Modern Python applications and projects provide the required files in order to list the package list which should be installed. We can use this requirement file in order to specify the packages we have to remove the requirement file. In this example, the requirement file contains the following content with the name of requirements.txt
.
现代Python应用程序和项目提供了必需的文件,以便列出应安装的软件包列表。 我们可以使用此需求文件来指定必须删除需求文件的软件包。 在此示例中,需求文件包含以下内容,其名称为requirements.txt
。
django
pycups
PyGObject
PyJWT
pymacaroons
PyNaCl
pyRFC3339
AND we will remove this requirements.txt file content like below.
并且我们将删除此requirements.txt文件内容,如下所示。
$ pip uninstall requirements.txt
无需询问Pip即可卸载/删除Python软件包 (Uninstall/Remove Python Package Without Asking Confirmation with Pip)
By default the package uninstallation or removal requires a confirmation from the user. This is generally providing the y
which is a short form of Yes
to accept package uninstall. We can automatically accept the confirmation and skip it with the -y
or --yes
option like below.
默认情况下,软件包的卸载或删除需要用户的确认。 通常,这是提供y
形式, Yes
接受软件包卸载的缩写。 我们可以自动接受确认,并使用-y
或--yes
选项跳过它,如下所示。
$ pip uninstall -y django
$ pip2 uninstall -y django
$ pip3 uninstall -y django
使用Pip卸载/删除特定用户的Python软件包 (Uninstall/Remove Python Package For Specific User with Pip)
pip Python packages may be installed for a specific user into the users home directory. So we can uninstall given python package for a specific user with the --user
option by providing the user name. In this example, we will remove packages for the current user.
pip Python软件包可以为特定用户安装到用户的主目录中。 因此,我们可以使用--user
选项通过提供用户名来卸载特定用户的给定python软件包。 在此示例中,我们将删除当前用户的软件包。
$ pip uninstall --user django
$ pip2 uninstall --user django
$ pip3 uninstall --user django
使用easy_install卸载/删除Python软件包 (Uninstall/Remove Python Package with easy_install)
We can also use the easy_install
command in order to remove installed python packages. We will use -m
option and provide the package name. In this example, we will remove the package named django with the easy_install command.
我们还可以使用easy_install
命令来删除已安装的python软件包。 我们将使用-m
选项并提供软件包名称。 在此示例中,我们将使用easy_install命令删除名为django的软件包。
$ easy_install -m django
.ue6353ce88552e6dbc1e8148a68b93656 , .ue6353ce88552e6dbc1e8148a68b93656 .postImageUrl , .ue6353ce88552e6dbc1e8148a68b93656 .centered-text-area{min-height:80px;position:relative;}
.ue6353ce88552e6dbc1e8148a68b93656 , .ue6353ce88552e6dbc1e8148a68b93656:hover , .ue6353ce88552e6dbc1e8148a68b93656:visited , .ue6353ce88552e6dbc1e8148a68b93656:active{border:0!important;}
.ue6353ce88552e6dbc1e8148a68b93656 .clearfix:after{content:””;display:table;clear:both;}
.ue6353ce88552e6dbc1e8148a68b93656{display:block;transition:background-color 250ms;webkit-transition:background-color 250ms;width:100%;opacity:1;transition:opacity 250ms;webkit-transition:opacity 250ms;background-color:#ECF0F1;box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);-o-box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);}
.ue6353ce88552e6dbc1e8148a68b93656:active , .ue6353ce88552e6dbc1e8148a68b93656:hover{opacity:1;transition:opacity 250ms;webkit-transition:opacity 250ms;background-color:#D35400;}
.ue6353ce88552e6dbc1e8148a68b93656 .centered-text-area{width:100%;position:relative;}
.ue6353ce88552e6dbc1e8148a68b93656 .ctaText{border-bottom:0 solid #fff;color:#3498DB;font-size:16px;font-weight:bold;margin:0;padding:0;text-decoration:underline;}
.ue6353ce88552e6dbc1e8148a68b93656 .postTitle{color:#27AE60;font-size:16px;font-weight:600;margin:0;padding:0;width:100%;}
.ue6353ce88552e6dbc1e8148a68b93656 .ctaButton{background-color:#e6e6e6!important;color:#3498DB;border:none;border-radius:3px;box-shadow:none;font-size:14px;font-weight:bold;line-height:26px;moz-border-radius:3px;text-align:center;text-decoration:none;text-shadow:none;width:80px;min-height:80px;background:url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat;position:absolute;right:0;top:0;}
.ue6353ce88552e6dbc1e8148a68b93656:hover .ctaButton{background-color:#E67E22!important;}
.ue6353ce88552e6dbc1e8148a68b93656 .centered-text{display:table;height:80px;padding-left:18px;top:0;}
.ue6353ce88552e6dbc1e8148a68b93656 .ue6353ce88552e6dbc1e8148a68b93656-content{display:table-cell;margin:0;padding:0;padding-right:108px;position:relative;vertical-align:middle;width:100%;}
.ue6353ce88552e6dbc1e8148a68b93656:after{content:””;display:block;clear:both;}
LEARN MORE How To Install Numpy For Linux?
.ue6353ce88552e6dbc1e8148a68b93656 , .ue6353ce88552e6dbc1e8148a68b93656 .postImageUrl , .ue6353ce88552e6dbc1e8148a68b93656 .centered-text-area{min-height:80px;position:relative;}
.ue6353ce88552e6dbc1e8148a68b93656 , .ue6353ce88552e6dbc1e8148a68b93656:hover , .ue6353ce88552e6dbc1e8148a68b93656:visited , .ue6353ce88552e6dbc1e8148a68b93656:active{border:0!important;}
.ue6353ce88552e6dbc1e8148a68b93656 .clearfix:after{content:””;display:table;clear:both;}
.ue6353ce88552e6dbc1e8148a68b93656{display:block;transition:background-color 250ms;webkit-transition:background-color 250ms;width:100%;opacity:1;transition:opacity 250ms;webkit-transition:opacity 250ms;background-color:#ECF0F1;box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);-o-box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.17);}
.ue6353ce88552e6dbc1e8148a68b93656:active , .ue6353ce88552e6dbc1e8148a68b93656:hover{opacity:1;transition:opacity 250ms;webkit-transition:opacity 250ms;background-color:#D35400;}
.ue6353ce88552e6dbc1e8148a68b93656 .centered-text-area{width:100%;position:relative;}
.ue6353ce88552e6dbc1e8148a68b93656 .ctaText{border-bottom:0 solid #fff;color:#3498DB;font-size:16px;font-weight:bold;margin:0;padding:0;text-decoration:underline;}
.ue6353ce88552e6dbc1e8148a68b93656 .postTitle{color:#27AE60;font-size:16px;font-weight:600;margin:0;padding:0;width:100%;}
.ue6353ce88552e6dbc1e8148a68b93656 .ctaButton{background-color:#e6e6e6!important;color:#3498DB;border:none;border-radius:3px;box-shadow:none;font-size:14px;font-weight:bold;line-height:26px;moz-border-radius:3px;text-align:center;text-decoration:none;text-shadow:none;width:80px;min-height:80px;background:url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat;position:absolute;right:0;top:0;}
.ue6353ce88552e6dbc1e8148a68b93656:hover .ctaButton{background-color:#E67E22!important;}
.ue6353ce88552e6dbc1e8148a68b93656 .centered-text{display:table;height:80px;padding-left:18px;top:0;}
.ue6353ce88552e6dbc1e8148a68b93656 .ue6353ce88552e6dbc1e8148a68b93656-content{display:table-cell;margin:0;padding:0;padding-right:108px;position:relative;vertical-align:middle;width:100%;}
.ue6353ce88552e6dbc1e8148a68b93656:after{content:””;display:block;clear:both;} 了解更多如何为Linux安装Numpy?
翻译自: https://www.poftut.com/how-to-uninstall-a-package-with-pip/
最新评论