Import conda error traceback upon opening terminal

限于喜欢 提交于 2019-12-30 09:54:12

问题


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?


回答1:


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!




回答2:


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.




回答3:


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"



回答4:


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



来源:https://stackoverflow.com/questions/59317257/import-conda-error-traceback-upon-opening-terminal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!