简体   繁体   English

无法使用 conda 卸载 keras

[英]Can't uninstall keras with conda

I somehow installed keras twice( 2.2.4 and 2.3.1 ) with conda (at least I think I did).我莫名其妙地安装了keras两次( 2.2.42.3.1含) conda (至少我觉得我做了)。 Now I am trying to uninstall both, the first one ( 2.2.4 ) I could uninstall with conda uninstall keras .现在我正在尝试卸载两者,第一个( 2.2.4 )我可以使用conda uninstall keras But this doesn't work for the second one.但这对第二个不起作用。

(base) keras_retinanet$ conda list keras
|# packages in environment at anaconda3:
│# Name                    Version                   Build  Channel
keras                     2.3.1                    pypi_0    pypi
keras-applications        1.0.8                      py_0  
keras-preprocessing       1.1.0                      py_1  
keras-resnet              0.1.0                    pypi_0    pypi
keras-retinanet           0.5.1                    pypi_0    pypi
(base) keras_retinanet$ conda uninstall keras
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are missing from the target environment:
- keras

How can I uninstall the second one?如何卸载第二个?

I already tried to uninstall keras with pip3:我已经尝试使用 pip3 卸载 keras:

WARNING: Skipping keras as it is not installed.警告:跳过 keras,因为它没有安装。

And when importing keras in python I get this path:在 python 中导入 keras 时,我得到了这个路径:

>>> keras.__path__
_NamespacePath(['.../anaconda3/lib/python3.7/site-packages/keras'])

Thanks谢谢

One option, when the package is installed by pip (that's what the channel pypi indicates) is to enable Conda to directly manipulate PyPI packages by enabling the pip_interop_enabled configuration option .一种选择是,当包由pip安装时(这就是通道pypi指示的)是通过启用pip_interop_enabled配置选项使 Conda 能够直接操作 PyPI 包。 You can do this temporarily via:您可以通过以下方式临时执行此操作:

CONDA_PIP_INTEROP_ENABLED=1 conda remove -n base keras

or you can turn this on globally或者你可以在全球范围内打开它

conda config --set pip_interop_enabled True
conda remove -n base keras

Just be aware that this is an experimental option, and I still strongly encourage following the best practice recommendations found in " Using Pip in a Conda Environment ".请注意,这是一个实验性选项,我仍然强烈建议您遵循“ 在 Conda 环境中使用 Pip ”中的最佳实践建议。

I'd recommend trying a couple of things:我建议尝试几件事:

  1. do a conda deactivate && conda activate base .做一个conda deactivate && conda activate base In my experience, conda can get into a bad state and this can help(even in the base environment).根据我的经验,conda 可能会进入不良状态,这会有所帮助(即使在基本环境中)。 Then pip uninstall keras然后pip uninstall keras

  2. If that doesn't work, you can try manually getting the path to your conda-installed pip and use that to uninstall keras .如果这不起作用,您可以尝试手动获取安装 conda 的pip的路径并使用它来卸载keras

Hope it helps.希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM