I managed to debug my problem further. The method I developed above works for every other environment except the one I need. The problem is that this environment has conda packages for osx-64 on my arm-64 machine.
They work correctly running Python code, but Julia seems conflicted with this platform change. I leave here some output I got debugging the PyCall build with that environment:
(flat_bands) pkg> build PyCall
Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/b19db3927f0db4151cb86d073689f2428e524576/build.log`
Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/9816a3826b0ebf49ab4926e2b18842ad8b5c8f04/build.log`
ERROR: Error building `PyCall`:
DEBUG is_windows = False
DEBUG is_apple = True
DEBUG Candidate: None
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/python3.9/config-3.9-darwin/libpython3.9.a
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/python3.9/config-3.9-darwin/libpython3.9.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/python3.9/config-3.9-darwin/libpython3.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/python3.9/config-3.9-darwin/libpython.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.a
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib
DEBUG Found: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/libpython3.9.a
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/libpython3.9.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/libpython3.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/libpython.dylib
DEBUG Not found.
DEBUG Candidate: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/bin/../lib/libpython3.9.dylib
DEBUG Found: /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib
dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib) ==> ErrorException("could not load library \"/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib\"\ndlopen(/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib, 0x0009): tried: '/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib' (no such file), '/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/lib/libpython3.9.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))")
dlopen(libpython3.9) ==> ErrorException("could not load library \"libpython3.9\"\ndlopen(libpython3.9.dylib, 0x0009): tried: 'libpython3.9.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpython3.9.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/libpython3.9.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/../libpython3.9.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/libpython3.9.dylib' (no such file), '/usr/lib/libpython3.9.dylib' (no such file, not in dyld cache), 'libpython3.9.dylib' (no such file), '/usr/local/lib/libpython3.9.dylib' (no such file), '/usr/lib/libpython3.9.dylib' (no such file, not in dyld cache)")
dlopen(libpython3.9) ==> ErrorException("could not load library \"libpython3.9\"\ndlopen(libpython3.9.dylib, 0x0009): tried: 'libpython3.9.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpython3.9.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/libpython3.9.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/../libpython3.9.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/libpython3.9.dylib' (no such file), '/usr/lib/libpython3.9.dylib' (no such file, not in dyld cache), 'libpython3.9.dylib' (no such file), '/usr/local/lib/libpython3.9.dylib' (no such file), '/usr/lib/libpython3.9.dylib' (no such file, not in dyld cache)")
dlopen(libpython3) ==> ErrorException("could not load library \"libpython3\"\ndlopen(libpython3.dylib, 0x0009): tried: 'libpython3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpython3.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/libpython3.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/../libpython3.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/libpython3.dylib' (no such file), '/usr/lib/libpython3.dylib' (no such file, not in dyld cache), 'libpython3.dylib' (no such file), '/usr/local/lib/libpython3.dylib' (no such file), '/usr/lib/libpython3.dylib' (no such file, not in dyld cache)")
dlopen(libpython) ==> ErrorException("could not load library \"libpython\"\ndlopen(libpython.dylib, 0x0009): tried: 'libpython.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibpython.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/libpython.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/julia/../libpython.dylib' (no such file), '/Users/antoniomoralesperez/.julia/juliaup/julia-1.11.3+0.aarch64.apple.darwin14/lib/libpython.dylib' (no such file), '/usr/lib/libpython.dylib' (no such file, not in dyld cache), 'libpython.dylib' (no such file), '/usr/local/lib/libpython.dylib' (no such file), '/usr/lib/libpython.dylib' (no such file, not in dyld cache)")
ERROR: LoadError: Couldn't find libpython; check your PYTHON environment variable.
The python executable we tried was /opt/homebrew/Caskroom/miniconda/base/envs/intel_env/bin/python (= version 3.9).
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/1gn3u/deps/buildutils.jl:80
[3] find_libpython(python::String)
@ Main ~/.julia/packages/PyCall/1gn3u/deps/buildutils.jl:48
[4] top-level scope
@ ~/.julia/packages/PyCall/1gn3u/deps/build.jl:82
[5] include(fname::String)
@ Main ./sysimg.jl:38
[6] top-level scope
@ none:5
in expression starting at /Users/antoniomoralesperez/.julia/packages/PyCall/1gn3u/deps/build.jl:43
Is it possible to indicate PyCall.jl
to use that osx-64 python environment without installing an osx-64 Julia using Rosetta?