4

The below lines of code show up every time I open my terminal.

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
ImportError: No module named conda

I am worried I have possibly corrupted my (base) conda environment but I haven't run into any issues so far. Mainly, it's just really annoying to see.

Using conda activate base gives no errors. All I was doing as of recently was removing and reinstalling different versions of opencv so that I would have a version that allows me to use imshow(). I also did path_to_env_python -m pip3 install common. Besides that I don't think I have done anything that would cause the issue.

Any ideas?

PoorProgrammer
  • 329
  • 2
  • 10
  • 3
    Looks like an issue introduced with conda `4.8.0`. Better revert conda to `4.7.12` for now, this one is stable. – FabienP Dec 13 '19 at 21:24

4 Answers4

4

Having the same issue. For me a temporary fix was commenting out the eval and its else if loop in bashrc.

There is a thread on this issue on the github of conda: https://github.com/conda/conda/issues/9505

edit: It was an error in 4.8.0 anaconda. In <conda_install>/etc/bash_completion.d/conda python was called without adding the path towards the anaconda python, with as a result that it opened python 2.7 and then tried to import conda. It has been fixed by the most recent update, so running conda update conda should fix the issue!

iklucas
  • 56
  • 3
1

I think this is related to an upstream issue since I am facing the same problem since this morning on two different machines. So I would suggest to not modify your RC files.

0

I had the same problem The reason is in .bashrc:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/myname/app/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/myname/app/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/myname/app/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/myname/app/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup

Problematic line:

eval "$__conda_setup"

Solved by replacing the whole block with:

export PATH="/home/myname/app/miniconda3/bin:$PATH"
  • This shouldn't be the case. Did you look any deeper into why it failed? Manually manipulating `PATH` in interactive sessions is strongly discouraged because it ends up leaking the **base** env into others that one might activate. – merv Dec 13 '19 at 14:03
  • Unfortunately, this solution breaks working ```conda activate``` from terminal – Alexey Chub Dec 13 '19 at 14:22
  • Working solution provided here: https://github.com/conda/conda/issues/9505 – Alexey Chub Dec 16 '19 at 07:43
0

The error has been fixed, you need to do a conda update conda in your terminal and it will work like a charm.

cnemri
  • 305
  • 2
  • 11