Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem specifying the python path on MacOs (Apple Silicon) #1089

Closed
AntonioMoralesPerez opened this issue Jan 22, 2025 · 2 comments
Closed

Comments

@AntonioMoralesPerez
Copy link

I was trying to change the Python executable from the one used by default to one in a Miniconda virtual environment that has already been created.

I followed the steps in README.md, but PyCall.jl seems to "ignore" me. I show here what happens:

julia> using PyCall; using Pkg

julia> ENV["PYTHON"] = "/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/bin/python3"
"/opt/homebrew/Caskroom/miniconda/base/envs/intel_env/bin/python3"

julia> 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`

julia>

Then after restarting Julia I try to see if the change have been performed and:

julia> using PyCall

julia> PyCall.python
"/Users/antoniomoralesperez/.julia/conda/3/aarch64/bin/python"

julia>

So, nothing has changed. It is strange because I have done this successfully in the past. Finally, here is some more info about my installation:

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 8 × Apple M2
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m2)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

julia>
@AntonioMoralesPerez
Copy link
Author

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?

@stevengj
Copy link
Member

No. The ARM Julia executable cannot link an x86_64 library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants