Conda won't remove package

Viewed 4350

Am I doing something wrong in my commands? I can't remove Keras.

$ conda remove --name myEnv keras
Collecting package metadata (repodata.json): done
Solving environment: failed

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


$ conda list --name myEnv keras
# packages in environment at /Users/me/anaconda3/envs/myEnv:
#
# Name                    Version                   Build  Channel
keras                     2.3.1                    pypi_0    pypi
3 Answers

The channel pypi for keras means you have mix used pip and conda. To uninstall the keras installed from pypi, use pip.

pip uninstall keras

It's not a good idea to mix use both package managers pip and conda in one environment. If you really need to. Read the official guide Using Pip in a Conda Environment.

conda remove --force (the rest of the command)

Pip Interoperability

As @Simba correctly identified, the package is from PyPI (i.e., it was installed via pip). By default, Conda can recognize the presence of such packages but will not interact with them. However, there is a "preview" configuration option, pip_interop_enabled, that enables such interaction (see Conda v4.6 Release Notes). You could either

  1. Set this option globally:

    conda config --set pip_interop_enabled true
    conda remove --name myEnv keras
    

    If you have PyPI packages generally, then this should help improve your env stability, but at the cost of slightly longer solve times, since now Conda will account for packages coming from PyPI.

  2. Temporarily turn it on just for this operation

    CONDA_PIP_INTEROP_ENABLED=1 conda remove --name myEnv keras
    
Related