PyCall.jl
PyCall.jl copied to clipboard
Dying Kernel on Apple M1
I was previously using Julia 1.6.3 on Rosetta and Python 3.9 installed for intel, with no issues. I've now moved to Julia 1.7.1 running natively on ARM, with Python 3.9 to match. I've installed PyCall using Pkg.add and Pkg.build, but the Julia kernel dies every time I attempt "using PyCall".
EDIT: Seeing the comment below, I tried it directly CLI Julia rather than in a Jupyter notebook, and I am indeed getting "No module named site"
I am getting an error that is probably the same. I am running Julia natively on an M1 Pro and am getting an ImportError: No module named site
.
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.1 (2021-12-22)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(@v1.7) pkg> status
Status `~/.julia/environments/v1.7/Project.toml`
[6e4b80f9] BenchmarkTools v1.2.2
[35d6a980] ColorSchemes v3.16.0
[8f4d0f93] Conda v1.6.0
[163ba53b] DiffResults v1.0.3
[7a1cc6ca] FFTW v1.4.5
[f6369f11] ForwardDiff v0.10.25
[f67ccb44] HDF5 v0.16.1
[f5a24dde] LimitedLDLFactorizations v0.4.1
[b8a86587] NearestNeighbors v0.4.9
[91a5bcdd] Plots v1.25.7
[af69fa37] Preconditioners v0.4.1
[438e738f] PyCall v1.93.0
[295af30f] Revise v3.3.1
[276daf66] SpecialFunctions v2.1.0
[2913bbd2] StatsBase v0.33.14
julia> using PyCall
ImportError: No module named site
Works for me on M1 (with Conda python). What python are you trying to link with?
I first tried it without changing the ENV["PYTHON"]
entry. I believe this should've defaulted to usr/bin/python3
, which is currently
Python 3.8.9 (default, Oct 26 2021, 07:25:53)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
After that failed with the above error, I first checked my Conda python
(base) MacBook-Pro:SEA python3
Python 3.8.8 (default, Apr 13 2021, 12:59:45)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(base) MacBook-Pro:SEA sebastianament$ which python
/Users/sebastianament/miniconda3/bin/python
And then tried
ENV["PYTHON"] = "/Users/sebastianament/miniconda3/bin/python"
"/Users/sebastianament/miniconda3/bin/python"
(@v1.7) pkg> build PyCall
Building Conda ─→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/6cdc8832ba11c7695f494c9d9a1c31e90959ce0f/build.log`
Building PyCall → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/71fd4022ecd0c6d20180e23ff1b3e05a143959c2/build.log`
Precompiling project...
✗ PyPlot
1 dependency successfully precompiled in 2 seconds (191 already precompiled)
1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
julia> using PyCall
ImportError: No module named site
Any ideas what else I could try?
I had the same error, I worked around it by adding the Conda
package and then manually re-building the PyCall
package with ENV["Python"]
unset (which will use conda if the Conda
julia package is installed). I'm not familiar enough with PyCall
to know for sure if it's expected to work without the Conda
julia package.