New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"ImportError: No module named conda" #9507
Comments
This is the snippet originally added by # >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/antoine/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/antoine/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/antoine/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/antoine/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<< If I comment out some of the lines thusly: # >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/antoine/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
# eval "$__conda_setup"
#else
if [ -f "/home/antoine/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/antoine/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/antoine/miniconda3/bin:$PATH"
fi
#fi
#unset __conda_setup
# <<< conda initialize <<< then the error disappears and the conda install still works. |
Hi there, I got the same error and investigated a bit. Short version of my findings at the end.
# line 26
function __comp_conda_ensure_root() {
# [...]
CONDA_SOURCE=$(
cat - <<' EOF' | sed 's/^ *: //g' | python -
: from __future__ import print_function
: import os
: import conda # <-- THERE
: print(os.path.dirname(conda.__file__))
EOF
)
# [...]
} I added a # line 26
function __comp_conda_ensure_root() {
# [...]
CONDA_SOURCE=$(
cat - <<' EOF' | sed 's/^ *: //g' | python -
: from __future__ import print_function
: import os
# ADDED LINES
: import sys
: raise ValueError("python: " + sys.version)
# END ADDED LINES
: import conda # <-- THERE
: print(os.path.dirname(conda.__file__))
EOF
)
# [...]
} While this obviously halts the execution, it showed that the python version was 2.7 - which I'm pretty sure should not be the case, this is a system python version, not the anaconda one. When looking at the # Lline 100
# cache conda subcommand help lookups for the duration of the shell
unset __comp_conda_cache
declare -A __comp_conda_cache
echo "$PATH" # ADDED LINE
__comp_conda_ensure_root and comparing with the TL;DR: The problem seems to be that the new file Hope this helps resolve the issue ! EDIT:
|
Same here (just updated to 4.8). The bug does not seem to affect any
|
I had the same issue after the conda update to 4.8.0. I was checking the init script and could reach the same conclusion as @QuentinSoubeyran. As the python version is from the system and not from the conda package, due to the path was not set before, I did a simple workaround: change the line 36 of CONDA_SOURCE=$(
cat - <<' EOF' | sed 's/^ *: //g' | python - # <<< Original
: from __future__ import print_function
: import os
: import conda
: print(os.path.dirname(conda.__file__))
EOF
) to: CONDA_SOURCE=$(
cat - <<' EOF' | sed 's/^ *: //g' | ${CONDA_PYTHON_EXE} - # <<< Changed
: from __future__ import print_function
: import os
: import conda
: print(os.path.dirname(conda.__file__))
EOF
) Now seems to be working normally and I don't have the error message when starting the shell. |
I can report the same problem on Ubuntu 18.04. After downgrading back to conda 4.7.12, it works fine. |
Looks like this is fixed in master by #9421 but was not included in the 4.8 release |
Issue seems solved by todayś update |
|
That fix only works for people using conda-forge. but I guess using conda-forge is your choice. |
|
fixed in 4.8.1, which is on conda-canary. Closing. |
I am still getting the error: I have installed Anaconda3-2019.10-Windows-x86_64 on windows 10 |
Hi @Vivek1717 , You have the I would suggest looking for your specific error online: this might help. If the problem is indeed due to your PATH, here is how to diagnose and solve it on windows. From memory, I also recall something about administrator privileges causing problems if conda was installed with admin rights and is run without. If you still experience the problem, it is best to create a dedicated issue to keep things organised. EDIT: added further references to potential solutions |
I tried the solutions stated but was unable to resolve the issue through them. However this post worked like a charm for me. |
Hi there, thank you for your contribution to Conda! This issue has been automatically locked since it has not had recent activity after it was closed. Please open a new issue if needed. |
I recently upgrade conda from 4.7.12 to 4.8.0 and now, every time I open a shell, I get this error:
Weirdly, conda still works:
If I remove the snippet added by
conda init
at the end of my.bashrc
, the error disappears (but of course conda is not in the PATH anymore). If I runconda init
again, the error reappears.The text was updated successfully, but these errors were encountered: