Skip to content

Commit bb7c9bb

Browse files
tkfstevengj
authored andcommitted
Do not run conda install automagically (unless Conda.jl is used) (#580)
fix #560
1 parent c45a076 commit bb7c9bb

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/PyCall.jl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -656,23 +656,14 @@ function pyimport_conda(modulename::AbstractString, condapkg::AbstractString,
656656
pyimport(modulename)
657657
else
658658
aconda = anaconda_conda()
659-
if !isempty(aconda)
660-
try
661-
Compat.@info "Installing $modulename via Anaconda's $aconda..."
662-
isempty(channel) || run(`$aconda config --add channels $channel --force`)
663-
run(`$aconda install -y $condapkg`)
664-
catch e2
665-
error("""
666-
Detected Anaconda Python, but \"$aconda install -y $condapkg\" failed.
667-
668-
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:
669-
ENV["PYTHON"]=""; Pkg.build("PyCall")
670-
after re-launching Julia.
671-
672-
The exception was: $e2
673-
""")
674-
end
675-
return pyimport(modulename)
659+
if isempty(aconda)
660+
# Not in conda environment; show the error from `pyimport`.
661+
rethrow()
662+
end
663+
664+
options = ""
665+
if !isempty(channel)
666+
options = " --channel $channel"
676667
end
677668

678669
error("""
@@ -683,6 +674,12 @@ function pyimport_conda(modulename::AbstractString, condapkg::AbstractString,
683674
Pkg.build("PyCall")
684675
before trying again.
685676
677+
Note that Conda.jl can use custom conda environment. Read more about `CONDA_JL_HOME` configuration in Conda.jl documentation:
678+
https://github.com/JuliaPy/Conda.jl
679+
680+
To install $condapkg using $aconda, you can run the following command from your system shell:
681+
$aconda install$options $condapkg
682+
686683
The pyimport exception was: $e
687684
""")
688685
end

0 commit comments

Comments
 (0)