JuliaPy / PyCall.jl

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

Cannot build PyCall, possibly due to incompatible architecture #1027

Closed giancarloantonucci closed 1 year ago

giancarloantonucci commented 1 year ago

I'm on macOS Ventura 13.1 (Apple M1 Pro) with Julia 1.8.5. When I run build PyCall, I get:

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

# All requested packages already installed.

┌ 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.

The python executable we tried was /Users/username/.julia/conda/3/bin/python (= version 3.10).
Re-building with
    ENV["PYCALL_DEBUG_BUILD"] = "yes"
may provide extra information for why it failed.

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] find_libpython(python::String; _dlopen::typeof(Base.Libc.Libdl.dlopen))
   @ Main ~/.julia/packages/PyCall/twYvK/deps/buildutils.jl:72
 [3] find_libpython(python::String)
   @ Main ~/.julia/packages/PyCall/twYvK/deps/buildutils.jl:40
 [4] top-level scope
   @ ~/.julia/packages/PyCall/twYvK/deps/build.jl:82
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:476
 [6] top-level scope
   @ none:5
in expression starting at /Users/username/.julia/packages/PyCall/twYvK/deps/build.jl:43

Looking around the web for a solution, I think the problem lies in Conda.jl not having selected the compatible architecture, somehow. At some point, I did in fact get the following error message when building PyCall: LoadError: could not load library "/Users/username/.julia/conda/3/lib/libpython3.10.dylib" dlopen(/Users/username/.julia/conda/3/lib/libpython3.10.dylib, 0x0009): tried: '/Users/username/.julia/conda/3/lib/libpython3.10.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/username/.julia/conda/3/lib/libpython3.10.dylib' (no such file), '/Users/username/.julia/conda/3/lib/libpython3.10.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')).

stevengj commented 1 year ago

Maybe you installed Conda with an earlier version of Julia that was running on Rosetta (x86 instruction), which no longer works now that you are using Julia running natively on ARM.

Try just deleting the conda installation and re-building, i.e. rm -rf /Users/username/.julia/conda.

giancarloantonucci commented 1 year ago

It's worked, thanks!