Hello,
I get an “ModuleNotFoundError: No module named ‘conda’” error when building a conda package through conda build.
Before the error triggers, conda-build actually does a lot of things successfully, like creating the package plans etc. Later in the process it dies when it wants to activate the build env.
I tried many things, like making sure I have only one env (so there is no python version mismatch), the paths are set correctly etc. Web-search does not give any other hints.
Below is the snippet of the log showing the error (using --debug). Any idea?
+++ xxxx/third_party/install/miniconda3/bin/python -m conda shell.bash hook
++ eval 'export CONDA_EXE='\''xxxx/third_party/install/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''xxxx/third_party/install/miniconda3/bin/python'\''
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
__conda_exe() (
"$CONDA_EXE" $_CE_M $_CE_CONDA "$@"
)
__conda_hashr() {
if [ -n "${ZSH_VERSION:+x}" ]; then
\rehash
elif [ -n "${POSH_VERSION:+x}" ]; then
: # pass
else
\hash -r
fi
}
__conda_activate() {
if [ -n "${CONDA_PS1_BACKUP:+x}" ]; then
# Handle transition from shell activated with conda <= 4.3 to a subsequent activation
# after conda updated to >= 4.4. See issue #6173.
PS1="$CONDA_PS1_BACKUP"
\unset CONDA_PS1_BACKUP
fi
\local ask_conda
ask_conda="$(PS1="${PS1:-}" __conda_exe shell.posix "$@")" || \return
\eval "$ask_conda"
__conda_hashr
}
__conda_reactivate() {
\local ask_conda
ask_conda="$(PS1="${PS1:-}" __conda_exe shell.posix reactivate)" || \return
\eval "$ask_conda"
__conda_hashr
}
conda() {
\local cmd="${1-__missing__}"
case "$cmd" in
activate|deactivate)
__conda_activate "$@"
;;
install|update|upgrade|remove|uninstall)
__conda_exe "$@" || \return
__conda_reactivate
;;
*)
__conda_exe "$@"
;;
esac
}
if [ -z "${CONDA_SHLVL+x}" ]; then
\export CONDA_SHLVL=0
# In dev-mode CONDA_EXE is python.exe and on Windows
# it is in a different relative location to condabin.
if [ -n "${_CE_CONDA:+x}" ] && [ -n "${WINDIR+x}" ]; then
PATH="$(\dirname "$CONDA_EXE")/condabin${PATH:+":${PATH}"}"
else
PATH="$(\dirname "$(\dirname "$CONDA_EXE")")/condabin${PATH:+":${PATH}"}"
fi
\export PATH
# We'\''re not allowing PS1 to be unbound. It must at least be set.
# However, we'\''re not exporting it, which can cause problems when starting a second shell
# via a first shell (i.e. starting zsh from bash).
if [ -z "${PS1+x}" ]; then
PS1=
fi
fi
conda activate base'
+++ export CONDA_EXE=xxxx/third_party/install/miniconda3/bin/conda
+++ CONDA_EXE=xxxx/third_party/install/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=xxxx/third_party/install/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=xxxx/third_party/install/miniconda3/bin/python
+++ '[' -z '' ']'
+++ export CONDA_SHLVL=0
+++ CONDA_SHLVL=0
+++ '[' -n '' ']'
+++++ dirname xxxx/third_party/install/miniconda3/bin/conda
++++ dirname xxxx/third_party/install/miniconda3/bin
+++ PATH=xxxx/third_party/install/miniconda3/condabin:xxxx/third_party/install/miniconda3/conda-bld/sharpy_1709127147272/_build_env/bin:xxxx/third_party/install/miniconda3/conda-bld/sharpy_1709127147272/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin:xxxx/third_party/install/miniconda3/bin:xxxx/third_party/install/miniconda3/condabin:xxxx/third_party/install/miniconda3/condabin:xxxx/third_party/install/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
+++ export PATH
+++ '[' -z '' ']'
+++ PS1=
+++ conda activate base
+++ local cmd=activate
+++ case "$cmd" in
+++ __conda_activate activate base
+++ '[' -n '' ']'
+++ local ask_conda
++++ PS1=
++++ __conda_exe shell.posix activate base
++++ xxxx/third_party/install/miniconda3/bin/conda shell.posix activate base
Traceback (most recent call last):
File "xxxx/third_party/install/miniconda3/bin/conda", line 12, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
+++ ask_conda=
+++ return