[英]How to uninstall package in Anaconda installed with pip
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
.我还使用python3 setup.py install
为它安装了很多软件包。 I used it for some packages created from setup.py
files.我将它用于从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 list
and pip3 list
and 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
PS I found info that conda uninstall
and conda remove
doesn't work in this case. PS 我发现conda uninstall
和conda remove
在这种情况下不起作用的信息。 But what to do then?但那该怎么办呢?
PSS Actually I changed real package name at packageName
but 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
You can use Jupyter Notebook to solve this problem :你可以使用 Jupyter Notebook 来解决这个问题:
!pip uninstall -y [package]
in a code cell在代码单元中输入!pip uninstall -y [package]
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 install wiki useful.您会发现卸载 setup.py 安装wiki 很有用。 Unix instructions quoted below: Unix 指令引用如下:
sudo python setup.py install --record files.txt
# inspect files.txt to make sure it looks ok. Then in bash:
tr '\n' '\0' < files.txt | xargs -0 sudo rm -f --
One has to be careful when using pip inside a conda environment, whether for installing and unistalling packages.在 conda 环境中使用 pip 时必须小心,无论是安装还是卸载软件包。 What works for me is based on https://stackoverflow.com/a/43729857/1047213 .对我有用的是基于https://stackoverflow.com/a/43729857/1047213 。
pip
that is specific to the conda environment by running conda install pip
inside the conda environment.安装pip
通过运行特定于畅达环境conda install pip
的畅达环境中。pip
while installing or uninstalling a package.在安装或卸载软件包时指定该特定pip
的完整路径。 Usually, you will find it inside the bin
folder of the virtual environment (eg, /anaconda/envs/venv_name/bin/
).通常,您会在虚拟环境的bin
文件夹中找到它(例如, /anaconda/envs/venv_name/bin/
)。 Thus, the following works for me: /anaconda/envs/venv_name/bin/pip install_or_uninstall package_name
.因此,以下对我/anaconda/envs/venv_name/bin/pip install_or_uninstall package_name
: /anaconda/envs/venv_name/bin/pip install_or_uninstall package_name
。Definitely the best way to uninstall all pypi packages in a conda environment is:在 conda 环境中卸载所有 pypi 包的最佳方法绝对是:
conda activate <your-env>
conda list | awk '/pypi/ {print $1}' | xargs pip uninstall -y
As shown in conda uninstall -h
detailed below,如下面详述的conda uninstall -h
所示,
--force-remove, --force
Forces removal of a package without removing packages
that depend on it. Using this option will usually
leave your environment in a broken and inconsistent
state.
So, I hold that your specific package packageName
is not well installed.所以,我认为你的特定包packageName
没有安装好。 That is, its dependent packages are not well installed, so you want to uninstall the package packageName
.也就是它的依赖包没有安装好,所以要卸载packageName
。 Further, conda uninstall packageName
failed, and you can try此外, conda uninstall packageName
失败,您可以尝试
conda uninstall packageName --force
, whose usage is the same as the commands pip uninstall packageName
and pip3 uninstall packageName
. ,其用法与pip uninstall packageName
和pip3 uninstall packageName
。 That is "removal of a package without removing packages that depend on it".那就是“删除一个包而不删除依赖它的包”。
Hope it works for you.希望它对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.