-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
grpcio fails to install on Apple Silicon #25082
Comments
I managed to get the grpcio Python package installed on Python 3.9.1 installed via Pyenv on a M1 macOS:
Native arm64:
I had to set a few environment variables to get it to work:
to make the installation process use the libraries I've already got on the system, and then the following to point it at OpenSSL installed via Homebrew:
|
you can use system python3 (/usr/bin/python3) mkdir grpctest
cd grpctest
/usr/bin/python3 -m pip install virtualenv
/usr/bin/python3 -m virtualenv venv
source venv/bin/activate __
arch -x86_64 pip install --upgrade pip setuptools
arch -x86_64 pip install grpcio
arch -x86_64 pip install grpcio-tools
touch test.proto
...
arch -x86_64 python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. test.proto
touch main.py
arch -x86_64 python main.py attention
|
@yoav-orca We currently doesn't have ARM64 machines to produce binary wheels, but we are working on a plan. Back to the build, the failure is not caused by the ASM optimization. Can you check the result of EDIT: if none presented, you could try to set it to your macOS version, e.g. Big Sur is |
I just tried to install the library from the master branch with the fix included, but it still fails out of the box. Is the version of BoringSSL and zlib referenced in this repository supposed to be working on ARM macOS? If not it might be better to try and detect when running on a ARM Mac (
Does that sound reasonable? If so, I don't mind trying to put a PR together to do that. |
@Tenzer That would be great if you can put up a PR, and you can ensure it works on the target machine (I don't have an Apple M1). |
I got a successful build using @Tenzer 's solution, with addition of CFLAGS and LDFLAGS using |
Thanks @Tenzer and @achimnol! This worked for me as well. Note if the following issue occurs after those recommendations: File "____/venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/version.py", line 275, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object Edit version.py line 275 on your system to: match = self._regex.search(str(version)) |
Setting the environment variables as recommended by @Tenzer works perfectly for me, too! Thank you! I used it to install stable_baselines3 on my Apple Silicon M1 🙂 I simply set the environment variables first:
Then installed the
At the time of writing this installs and works with @lidizheng @Tenzer Since it seems like this problem is not yet resolved I would offer help creating a PR, however I am completely new to this kind of stuff (pip install, setuptools etc.) and don't really know where I would have to put the code. This is what I think would have to go somewhere according to your contributions: import platform
import os
from distutils import util
if 'arm64' in platform.machine() and 'mac' in util.get_platform():
os.environ["GRPC_PYTHON_BUILD_SYSTEM_OPENSSL"] = "1"
os.environ["GRPC_PYTHON_BUILD_SYSTEM_ZLIB"] = "1"
else:
pass Maybe in setup.py around line 82? Of course the required import statements are there already. My SetupDevice: Apple M1 MacBook Pro running
Let me know if there is any more info that could be helpful! I also added the wheel generated by pip if that is helpful to anyone. |
I tried doing many of the above, and unfortunately all failed for me. Ended up getting it to work by following the steps here (but for grpcio) https://stackoverflow.com/questions/65564673/how-do-i-import-pandas-on-apple-m1-chip. Posting in case it's helpful to anyone in the future. |
Still having this problem after having tried the above. Also, the listed solutions are pretty involved workarounds. Is someone working on a more permanent fix? |
Yes, someone please respond ... I've already burned over 2 days on this error!! I've tried Homebrew w Py3.8, Py3.9 and Conda-miniforge with both as well I've even tried the Panda's example above but it didn't solve the problem for me... How do I install and run this library?? The failure stacktrace is below: import google.cloud.ndb as ndb |
@dgaedcke I don't have a M1 machine. The answer is based on what I read. Have you try to build your environment with emulated x86? arch -x86_64 /bin/bash Then you should be able to use x86 Python, and x86 |
Thanks for your response. |
I couldn't easily get a build process working on my Monterey M1, but the binary worked. Details: Setting the two environment variables still left me with
when trying to Maybe "If we export magic variables from the conda recipe, keep conda libraries installed and install Cython, then" would have worked, but I don't understand this enough to do it confidently (keep what installed how?). I haven't read the whole thread.
Installing the binary wheel from the latest artifact at https://github.com/pietrodn/grpcio-mac-arm-build/actions by downloading it and
worked a treat. Thank you so much!! <3 |
Confirming python 3.10.6 works on Monterey 12.5 (M1 Pro) with no env vars set. 3.9 did not seem to work for me with any of the incantations above. |
Would it be fair to say that this issue is not resolved? Should there be another one opened, or this one perhaps? We've got OSS users that encounter this problem somewhat regularly |
Of course the issue should be open, it is not fixed. I don't understand the trend on GitHub to close issues before a fix has been created, it is not like the issue goes away just by marking the issue closed:( Now it is almost 2 years since the issue was created and nobody cares enough about this to actually do the work needed to fix it. It is really frustrating that an important package like this can not be installed by pip without problems. On my Mac m1 12.6 python 3.10.6 I was not able to install 1.50.0 I simply gave up trying get it compiled :( and installed 1.46.3 with the following env vars set: Not sure if the env vars matter though |
Just to follow up on my previous comment, it turned out I could not use version 1.46.3. Anyway I managed to install version grpcio version 1.50.0. My pyenv was pulling in libraries for macOS 12.4 and after I updated pyenv and reinstalled python versions 3.10.6 (which pyenv builds from source) I could install grpcio version 1.50.0. Here are the commands I used: |
Yeah it is absolutely true, I spent like 2 hours trying to install it without venv, nothing really helps... |
Hello, since Google is doing nothing about this, I decided to set up a periodic GitHub Actions workflow to provide daily builds of Apple Silicon wheels for Mac. It will automatically cut a new release the day a new In the releases page of this repo you can find and download the wheels for Python 3.8, 3.9, 3.10, 3.11. |
I found out that setuptools-65.5.0 seems not able to install the latest grpcio-2.10.0, so I choose to install grpcio2.9.0 and then it works. |
@pietrodn Thanks 👍👍 |
@pietrodn the issues appear to also affect the |
Official macOS ARM builds seem to land in GRPC 1.52: #31747 Also GRPC 1.51 builds in under a minute from source for me on a M1 without any env variables set. |
@levrik Yes, to confirm, 1.52.0 includes prebuilt universal2 artifacts which work on both x86-64 and arm64 macs. The release candidate is already uploaded and the official release is scheduled for later this week. |
1.52.0 has been released with proper universal2 artifacts which support both x86 macs and M1/2 macs. |
1.52.0 is Yanked |
Can we re-open? |
I can see that there is a new release https://github.com/grpc/grpc/releases/tag/v1.52.1 and that was announced for today. But it is not published on PyPI.... |
1.51.2 is an unrelated C++-only patch release for a security vulnerability affecting only the C++ API. The release process for 1.51.3, which backports universal2 artifacts, is in progress and is still estimated to be complete today. |
Due to an issue with the CI build, the estimate is now Tuesday, February 28th. |
1.51.3 has now been released with universal2 artifacts. I'll leave this issue open for a couple more days in case there are further issues. |
What version of gRPC and what language are you using?
grpcio-1.34.0
What operating system (Linux, Windows,...) and version?
macOS big Sur 11.0.1, running on M1 Apple Silicon
What runtime / compiler are you using (e.g. python version or version of gcc)
What did you do?
Please provide either 1) A unit test for reproducing the bug or 2) Specific steps for us to follow to reproduce the bug. If there’s not enough information to debug the problem, gRPC team may close the issue at their discretion. You’re welcome to re-open the issue once you have a reproduction.
pip install grpcio==1.34.0
What did you expect to see?
That grpcio will be successfully installed
What did you see instead?
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
See TROUBLESHOOTING.md for how to diagnose problems better.
Anything else we should know about your project / environment?
The text was updated successfully, but these errors were encountered: