diff --git a/src/PyCall.jl b/src/PyCall.jl index a664ccf4..8e5ccc46 100644 --- a/src/PyCall.jl +++ b/src/PyCall.jl @@ -656,23 +656,14 @@ function pyimport_conda(modulename::AbstractString, condapkg::AbstractString, pyimport(modulename) else aconda = anaconda_conda() - if !isempty(aconda) - try - Compat.@info "Installing $modulename via Anaconda's $aconda..." - isempty(channel) || run(`$aconda config --add channels $channel --force`) - run(`$aconda install -y $condapkg`) - catch e2 - error(""" - Detected Anaconda Python, but \"$aconda install -y $condapkg\" failed. - - You should either install $condapkg manually or fix your Anaconda installation so that $aconda works. Alternatively, you can reconfigure PyCall to use its own Miniconda installation via the Conda.jl package, by running: - ENV["PYTHON"]=""; Pkg.build("PyCall") - after re-launching Julia. - - The exception was: $e2 - """) - end - return pyimport(modulename) + if isempty(aconda) + # Not in conda environment; show the error from `pyimport`. + rethrow() + end + + options = "" + if !isempty(channel) + options = " --channel $channel" end error(""" @@ -683,6 +674,12 @@ function pyimport_conda(modulename::AbstractString, condapkg::AbstractString, Pkg.build("PyCall") before trying again. + Note that Conda.jl can use custom conda environment. Read more about `CONDA_JL_HOME` configuration in Conda.jl documentation: + https://github.com/JuliaPy/Conda.jl + + To install $condapkg using $aconda, you can run the following command from your system shell: + $aconda install$options $condapkg + The pyimport exception was: $e """) end