Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I installed 64 bit Linux version of Anaconda recently (1.8.0-Linux-x86_64). The installation seemed to work fine:

$ python 
Python 2.7.5 |Continuum Analytics, Inc.| (default, Nov  4 2013, 15:30:26)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
##No issues here 

However if I try any of the conda commands, I get an error:

$ conda info
Traceback (most recent call last):
  File "~/anaconda/bin/conda", line 3, in <module>
    from conda.cli import main
ImportError: No module named conda.cli

Installation is under my user directory (~/anaconda). I have verified that $PATH contains ~/anaconda/bin. $PYTHONPATH is also set to ~/anaconda/lib.

Any thoughts on what is wrong with the 'conda' command? My searches do not appear to show any one else reporting this error.

like image 462
pk45059 Avatar asked Nov 06 '13 23:11

pk45059


People also ask

Can you pip install Conda?

You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.

Can I install Conda if I already have Python?

I already have Python installed. Can I install Anaconda? You do not need to uninstall other Python installations or packages before installing Anaconda.


2 Answers

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.

like image 129
Anwarvic Avatar answered Oct 02 '22 17:10

Anwarvic


When you were installing it, you missed a section. When conda asked you if it can set your .bashrc file, you probably clicked NO. It's a simple fix: fire up your interpreter and add this line:

export PATH=/home/add your username here/anaconda/bin:$PATH

Now type python into the interpreter and you will see Anaconda 1.8.0 or whatever version you have. You will have to do this each time you start a new interpreter.

Enjoy!

like image 26
RubyGladiator Avatar answered Oct 02 '22 17:10

RubyGladiator