After Anaconda installation, conda command fails with “ImportError: no module named conda.cli”

Note

If the accepted answer doesn’t work, then this answer might help.

The Cause

According to the official thread on GitHub, this problem happens when there is a change in the python version. In my case, the original anaconda installation is anaconda 3 with python3.6. And I installed a new package which updated python topython3.7 along with some other packages. And this corrupts the anaconda base environment.

The solution

The solution that works for me is pretty simple… reinstall anaconda.
I don’t know if this is the optimal solution, but this what works for me.

  • First we need to delete the old installation:
    rm -rf ~/anaconda3
    rm -rf ~/.condarc ~/.conda ~/.continuum
    
  • Then, reinstall Anaconda.

  • Finally, update all packages (including conda itself) using:

    conda update --all
    

Now, your anaconda is up-to-date.

Leave a Comment