Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
761 views
in Technique[技术] by (71.8m points)

python - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...