如何卸载使用pip install --user安装的软件包 [英] How to uninstall a package installed with pip install --user

查看:403
本文介绍了如何卸载使用pip install --user安装的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pip有一个--user选项,可以为每个用户安装Python软件包:

There is a --user option for pip which can install a Python package per user:

pip install --user [python-package-name]

我使用此选项在没有root访问权的服务器上安装软件包.我现在需要的是在当前用户上卸载已安装的软件包.我试图执行此命令:

I used this option to install a package on a server for which I do not have root access. What I need now is to uninstall the installed package on the current user. I tried to execute this command:

pip uninstall --user [python-package-name]

但是我得到了

no such option: --user

除了手动查找和删除软件包之外,如何卸载用pip install --user安装的软件包?

How can I uninstall a package that I installed with pip install --user, other than manually finding and deleting the package?

我找到了这篇文章

pip无法从每个用户的站点软件包目录中卸载

描述了不支持从用户目录卸载软件包.根据该文章,如果正确实施,则使用

which describes that uninstalling packages from user directory does not supported. According to the article if it was implemented correctly then with

pip uninstall [package-name]

还将在用户目录中搜索已安装的软件包.但是对我来说仍然是一个问题.如果在系统范围和每个用户都安装了相同的软件包,该怎么办? 如果有人需要定位特定的用户目录怎么办?

the package that was installed will be also searched in user directories. But a problem still remains for me. What if the same package was installed both system-wide and per-user? What if someone needs to target a specific user directory?

推荐答案

已经在Linux上使用Python 3.5和pip 7.1.2对此进行了测试,情况似乎是这样的:

Having tested this using Python 3.5 and pip 7.1.2 on Linux, the situation appears to be this:

  • pip install --user somepackage安装到$HOME/.local,并使用pip uninstall somepackage进行卸载.

  • pip install --user somepackage installs to $HOME/.local, and uninstalling it does work using pip uninstall somepackage.

无论是否同时在全系统范围内安装了somepackage,这都是正确的.

This is true whether or not somepackage is also installed system-wide at the same time.

如果在两个位置都安装了该软件包,则只​​会卸载本地软件包.要使用pip卸载系统范围的软件包,请先在本地将其卸载,然后使用root特权再次运行相同的卸载命令.

If the package is installed at both places, only the local one will be uninstalled. To uninstall the package system-wide using pip, first uninstall it locally, then run the same uninstall command again, with root privileges.

除了预定义的用户安装目录外,pip install --target somedir somepackage还将软件包安装到somedir中.无法使用pip从这样的位置卸载软件包. (但是在Github上有一个实现了pip uninstall --target的未合并的合并请求.)

In addition to the predefined user install directory, pip install --target somedir somepackage will install the package into somedir. There is no way to uninstall a package from such a place using pip. (But there is a somewhat old unmerged pull request on Github that implements pip uninstall --target.)

由于pip只能从系统范围和预定义的用户本地卸载,因此您需要以各自的用户身份运行pip uninstall,才能从给定用户的本地安装目录中卸载. p>

Since the only places pip will ever uninstall from are system-wide and predefined user-local, you need to run pip uninstall as the respective user to uninstall from a given user's local install directory.

这篇关于如何卸载使用pip install --user安装的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆