问题
I installed conda, not anaconda, directly onto a server I am working on using the following instructions
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh
install to $HOME/.miniconda2
edit ~/.bashrc
Add this line:
export PATH="$HOME/.miniconda2/bin:$PATH"
source ~/.bashrc
conda install pip
When the conda installer asked me if I want to add the path to my .bashrc file I said yes and it added export PATH="/home/r/rhlozek/binesh/miniconda2/bin:$PATH"
However whenever I try to do conda install pip
I get
Traceback (most recent call last):
File "/home/r/rhlozek/binesh/miniconda2/bin/conda", line 4, in <module>
import conda.cli
ImportError: No module named conda.cli
When other people have this issue is when they say "No" to when the conda installer asks them to edit their .bashrc file, but i say Yes to it so now I don't know why I'm running into this problem.
回答1:
Looks like your PYTHONPATH is not properly set. Check it with:
python
...
>>> import sys
>>> sys.path
It should have a bunch of paths in there. Something like 6 to 10 entries seem sensible. The actual number depends on your own settings. I don't have Linux available right now to test it. If this list is empty, very short, or contains only paths with prefixes other than /home/r/rhlozek/binesh/miniconda2
, you have problem.
Try:
- to start a new terminal window and see if the problem goes away and the PYTHONPATH gets longer
add paths manually with:
export PYTHONPATH="$HOME/.miniconda2/lib/python2.7:$HOME/.miniconda2/lib/python2.7/site-packages:$PYTHONPATH"
(Check for the actual path on your system)
source ~/.bashrc
回答2:
I got the same issues with miniconda3. None of workarounds work for me in https://github.com/conda/conda/issues/9507 and https://github.com/conda/conda/issues/2463, though all those issues seems pretty similar.
I uninstall miniconda by rm ~/miniconda
and reinstall it from https://docs.conda.io/en/latest/miniconda.html. Then the error disappears and the conda
works.
回答3:
On Windows : go to "System Properties" -> "Environment Variables" -> clear value of "PYTHONPATH"
来源:https://stackoverflow.com/questions/44784644/conda-importerror-no-module-named-conda-cli