Python 如何在使用 pip 安装的 Anaconda 中卸载软件包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48337016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:39:12  来源:igfitidea点击:

How to uninstall package in Anaconda installed with pip

pythonpipanaconda

提问by Mikhail_Sam

The problem:

问题:

I have installed Anaconda:

我已经安装了 Anaconda:

conda -V
conda 4.4.7

Also I installed a lot of packages for it using python3 setup.py install. I used it for some packages created from setup.pyfiles.

此外,我使用python3 setup.py install. 我将它用于一些从setup.py文件创建的包。

Now I want to uninstall one package.

现在我想卸载一个包。

What I tried:

我试过的:

pip uninstall packageName
pip3 uninstall packageName
conda uninstall packageName

It works for python: check pip listand pip3 listand there isn't such package.

它适用于python:检查pip list并且pip3 list没有这样的包。

Error:

错误:

But for conda I got this:

但是对于 conda 我得到了这个:

conda uninstall packageName
Solving environment: failed

PackagesNotFoundError: The following packages are missing from the target environment:
  - packageName

Let's check:

让我们检查:

conda list
packageName

P.S. I found info that conda uninstalland conda removedoesn't work in this case. But what to do then?

PS我发现该信息conda uninstallconda remove没有在这种情况下工作。但那该怎么办呢?

P.S.S. Actually I changed real package name at packageNamebut if this information is important I will add it.

PSS 实际上,我更改了真实的包名,packageName但如果此信息很重要,我会添加它。



My info:

我的信息:

conda info

     active environment : None
       user config file : /home/masamok4/.condarc
 populated config files : /home/masamok4/anaconda3/.condarc
                          /home/masamok4/.condarc
          conda version : 4.4.7
    conda-build version : 3.0.27
         python version : 3.6.3.final.0
       base environment : /home/masamok4/anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.continuum.io/pkgs/main/linux-64
                          https://repo.continuum.io/pkgs/main/noarch
                          https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/r/linux-64
                          https://repo.continuum.io/pkgs/r/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
          package cache : /home/masamok4/anaconda3/pkgs
                          /home/masamok4/.conda/pkgs
       envs directories : /home/masamok4/anaconda3/envs
                          /home/masamok4/.conda/envs
               platform : linux-64
             user-agent : conda/4.4.7 requests/2.18.4 CPython/3.6.3 Linux/4.4.0-87-generic ubuntu/16.04 glibc/2.23
                UID:GID : 1003:1003
             netrc file : None
           offline mode : False

回答by Abhinav Sood

If you installed the package using setup.py, then you will most likely have to delete the package files manually.

如果您使用 安装了软件包setup.py,那么您很可能必须手动删除软件包文件。

You'd find the Uninstalling setup.py installwiki useful. Unix instructions quoted below:

您会发现卸载 setup.py 安装wiki 很有用。Unix 指令引用如下:

sudo python setup.py install --record files.txt
# inspect files.txt to make sure it looks ok. Then in bash:
tr '\n' '##代码##' < files.txt | xargs -0 sudo rm -f --

回答by Lo?c

You can use Jupyter Notebook to solve this problem :

你可以使用 Jupyter Notebook 来解​​决这个问题:

  • open Jupyter Notebook
  • open a new notebook with the right kernel
  • type !pip uninstall -y [package]in a code cell
  • run the cell code
  • 打开 Jupyter Notebook
  • 用正确的内核打开一个新笔记本
  • 输入!pip uninstall -y [package]代码单元格
  • 运行单元格代码