# Setting Conda enviroment as Python executable for PyCall.jl

**URL:** <https://discourse.julialang.org/t/setting-conda-enviroment-as-python-executable-for-pycall-jl/125132>\
**Category:** General Usage\
**Tags:** pycall\
**Created:** [January 23, 2025, 4:07pm UTC](https://discourse.julialang.org/t/setting-conda-enviroment-as-python-executable-for-pycall-jl/125132 "2025-01-23T16:07:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonioMoralesPerez](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoniomoralesperez/32/214893_2.png) [@AntonioMoralesPerez](https://discourse.julialang.org/u/AntonioMoralesPerez)\
**Post date:** [January 23, 2025, 4:07pm UTC](https://discourse.julialang.org/t/setting-conda-enviroment-as-python-executable-for-pycall-jl/125132/1 "2025-01-23T16:07:56Z")

</div>

I tried to change the Python executable on `PyCall.jl` but it doesn’t change after building. Some code showing my problem:

```julia
❯ julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.11.3 (2025-01-21)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

(@v1.11) pkg> activate .
  Activating project at `~/phd/tb/referee_report`

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

(referee_report) 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> exit()
❯ julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.11.3 (2025-01-21)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

(@v1.11) pkg> activate .
  Activating project at `~/phd/tb/referee_report`

julia> using PyCall

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

julia>

```

---

<div class="post-metadata">

**Author:** ![AntonioMoralesPerez](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoniomoralesperez/32/214893_2.png) [@AntonioMoralesPerez](https://discourse.julialang.org/u/AntonioMoralesPerez)\
**Post date:** [January 24, 2025, 11:27am UTC](https://discourse.julialang.org/t/setting-conda-enviroment-as-python-executable-for-pycall-jl/125132/2 "2025-01-24T11:27:21Z")

</div>

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:

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

---

<div class="post-metadata">

**Author:** ![mraic1](https://avatars.discourse-cdn.com/v4/letter/m/6bbea6/32.png) [@mraic1](https://discourse.julialang.org/u/mraic1)\
**Post date:** [June 9, 2026, 6:40am UTC](https://discourse.julialang.org/t/setting-conda-enviroment-as-python-executable-for-pycall-jl/125132/3 "2026-06-09T06:40:17Z")

</div>

I had a more fundamental problem. As Apple announced that `x64` versions will no longer work in the next version of macOS (without Rosetta), I added an `aarch64` channel. However, even after many desparate attempts, `PyCall` did not work: I was unable to persuade `conda` to create and use the folder `~/.julia/conda/3/aarch64`: only `~/.julia/conda/3/x86_64` existed.

What helped was to change the installation method. As recommended, Julia was installed by  
`curl -fsSL https://install.julialang.org | sh` . After removing this installation and installling Julia by Homebrew, everything seems to work fine. No need to install Rosetta.

It would be great if somebody else finds this useful. All the best!
