JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.47k stars 187 forks source link

PyCall broken on M1 Mac and Julia 1.8.2? #1010

Closed GlenHenshaw closed 1 year ago

GlenHenshaw commented 1 year ago

Just upgraded to Julia 1.8.2, under macOS 12.6. python is installed via homebrew. I am getting the following error when running update:

julia> import Pkg

julia> Pkg.build("PyCall")
    Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/6e47d11ea2776bc5627421d59cdcc1296c058071/build.log`
    Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/53b8b07b721b77144a0fbbbc2675222ebf40a02d/build.log`
ERROR: Error building `PyCall`:
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

Retrieving notices: ...working... done
┌ Info: Using the Python distribution in the Conda package by default.
└ To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").
[ Info: Running `conda install -y numpy` in root environment
ERROR: LoadError: Couldn't find libpython; check your PYTHON environment variable.

when digging down, I finally arrive at the following:

dlopen(/Users/glenhenshaw/.julia/conda/3/lib/libpython3.9.dylib) ==> ErrorException("could not load library \"/Users/glenhenshaw/.julia/conda/3/lib/libpython3.9.dylib\"\ndlopen(/Users/glenhenshaw/.julia/conda/3/lib/libpython3.9.dylib, 0x0009): tried: '/Users/glenhenshaw/.julia/conda/3/lib/libpython3.9.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))")
stevengj commented 1 year ago

Your libpython is probably for the wrong architecture. You'll need to re-install Conda if you switch from using a Rosetta Julia to the native M1 Julia. rm(homedir() * "/.julia/conda", recursive=true) and try again.

AbhimanyuAryan commented 1 year ago

@GlenHenshaw does this also fix this issue? https://github.com/JuliaPy/PyCall.jl/issues/1017#issuecomment-1372031214

AbhimanyuAryan commented 1 year ago

I think I also saw this libpython errror. I remove ~/.julia/conda but that didn't fix the issue

AbhimanyuAryan commented 1 year ago

I have miniconda installed on my mac machine. Is that messing up with PyCall's conda?

hhaensel commented 1 year ago

Maybe. Have you tried

julia> ENV["CONDA_JL_CONDA_EXE"] = "/path/to/miniconda/bin/conda" # change this to the path of the conda executable

pkg> build Conda

More Info is on https://github.com/JuliaPy/Conda.jl

AbhimanyuAryan commented 1 year ago

@hhaensel I also think it's picking conda env from my ~/minicoda. Not sure though. It has something do with architecture. I didn't get time to debug this properly :(