SciPy.jl icon indicating copy to clipboard operation
SciPy.jl copied to clipboard

Installation issue macOS(Intel) in the case of `PyCall.conda` is `true`

Open terasakisatoshi opened this issue 2 years ago • 3 comments

https://github.com/AtsushiSakai/SciPy.jl/issues/48 (linux installation)

It seems there is a similar issue that happens on macOS (Intel) ʅ(◞‿◟)ʃ

u               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.2 (2022-09-29)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using PyCall

julia> PyCall.conda
true

julia> pyimport("scipy")
INTEL MKL ERROR: dlopen(/Users/terasakisatoshi/.julia/conda/3/lib/libmkl_intel_thread.1.dylib, 0x0009): Library not loaded: '@rpath/libiomp5.dylib'
  Referenced from: '/Users/terasakisatoshi/.julia/conda/3/lib/libmkl_intel_thread.1.dylib'
  Reason: tried: '/Applications/Julia-1.8.app/Contents/Resources/julia/bin/../lib/libiomp5.dylib' (no such file), '/usr/local/lib/libiomp5.dylib' (no such file), '/usr/lib/libiomp5.dylib' (no such file).
Intel MKL FATAL ERROR: Cannot load libmkl_intel_thread.1.dylib.

"'/usr/lib/libiomp5.dylib' (no such file)"

Ref https://github.com/JuliaPy/PyCall.jl/issues/895

So far I have no idea how to avoid the error.

terasakisatoshi avatar Nov 08 '22 13:11 terasakisatoshi

Fortunately, we can import scipy on windows 😅

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.8.2 (2022-09-29)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> versioninfo()
Julia Version 1.8.2
Commit 36034abf26 (2022-09-29 15:21 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, icelake-client)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_PROJECT = @.

julia> using PyCall; scipy = pyimport("scipy");

julia> PyCall.conda
true

julia> scipy.__version__
"1.9.3"

terasakisatoshi avatar Nov 08 '22 13:11 terasakisatoshi

(´・ω・`)つ 💊

import PyCall
PyCall.Conda.rm("mkl")
PyCall.Conda.add("nomkl")
PyCall.Conda.add("scipy=1.8.0"; channel="conda-forge") # we also could set "scipy=1.9.3"

Ref: https://github.com/JuliaPy/PyPlot.jl/issues/315#issuecomment-814652753

(It actually works, however, I'm not sure this is the best solution so far)

terasakisatoshi avatar Nov 08 '22 13:11 terasakisatoshi

🤔 Should we add in deps/build.jl

using PyCall
if PyCall.conda
    if Sys.islinux() && ...
        ...
    end
    if Sys.isapple() && Sys.ARCH === :x86_64
        buf = IOBuffer()
        PyCall.Conda.export_list(buf)
        for s in buf |> take! |> String |> split
            if occursin(r"^mkl=", s)
                PyCall.Conda.rm("mkl")
            end
        end
        PyCall.Conda.add("nomkl")
        PyCall.Conda.add("scipy=1.8.0"; channel="conda-forge")
    end
end

terasakisatoshi avatar Nov 08 '22 14:11 terasakisatoshi