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

Failed to load PyCall on M1 Mac #911

Closed
dk1013 opened this issue Jun 18, 2021 · 2 comments
Closed

Failed to load PyCall on M1 Mac #911

dk1013 opened this issue Jun 18, 2021 · 2 comments

Comments

@dk1013
Copy link

dk1013 commented Jun 18, 2021

I have installed Julia using official installer on a M1 Mac and installed PyCall with below command:
Pkg.add(PackageSpec(name="PyCall", rev="master"))
When I tried to import PyCall, I got the error: "ImportError: No module named site", and the terminal just died.
I'm not using a custom path for Python.
Any idea?

@stevengj
Copy link
Member

stevengj commented Jun 18, 2021

What is the output of pkg> build -v PyCall?

@dk1013
Copy link
Author

dk1013 commented Jun 22, 2021

Hi @stevengj , sorry for the late reply.
Following your hint, I managed to rebuild it and got it work.
Initially, I got this output:

(@v1.6) pkg> build -v PyCall
Building Conda ─→ ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/299304989a5e6473d985212c28928899c74e9421/build.log
Building PyCall → ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/169bb8ea6b1b143c5cf57df6d34d022a7b60c6db/build.log
[ Info: PyCall is using /Users/.../miniforge3/envs/.../bin/python (Python 3.9.0) at /Users/.../miniforge3/envs/.../bin/python, libpython = /System/Library/Frameworks/Python.framework/Versions/2.7/Python
[ Info: /Users/.../.julia/packages/PyCall/BD546/deps/deps.jl has not changed
[ Info: /Users/.../.julia/prefs/PyCall has not changed

So it seems it's because it's linked to my own Python. After resetting ENV["PYTHON"] and rebuild, now it works. The output is:

(@v1.6) pkg> build -v PyCall
Building Conda ─→ ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/299304989a5e6473d985212c28928899c74e9421/build.log
Building PyCall → ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/169bb8ea6b1b143c5cf57df6d34d022a7b60c6db/build.log
┌ 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
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
[ Info: PyCall is using /Users/.../.julia/conda/3/bin/python (Python 3.8.5) at /Users/.../.julia/conda/3/bin/python, libpython = /Users/.../.julia/conda/3/lib/libpython3.8.dylib
[ Info: /Users/.../.julia/packages/PyCall/BD546/deps/deps.jl has not changed
[ Info: /Users/.../.julia/prefs/PyCall has not changed

Now the issue can be closed.
Thank you!

@dk1013 dk1013 closed this as completed Jun 22, 2021
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