grpc: grpcio or grpcio-tools does not anymore compile with Apple M1 chip on 1.40.1 but works on 1.40.0

What version of gRPC and what language are you using?

Both 1.40.1 and 1.40.0

What operating system (Linux, Windows,…) and version?

Apple maxOS Big Sur 11.6

What runtime / compiler are you using (e.g. python version or version of gcc)

Python 3.10.0rc2

What did you do?

When I compile protobuf with 1.40.1 I get error

 File "/Users/user/.venv/lib/python3.10/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/Users/user/.venv/lib/python3.10/site-packages/grpc/_compression.py", line 15, in <module>
    from grpc._cython import cygrpc
ImportError: dlopen(/Users/user/.venv/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so, 2): no suitable image found.  Did find:
	/Users/user/.venv/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so: mach-o, but wrong architecture
	/Users/user/.venv/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so: mach-o, but wrong architecture

If I use 1.40.0, protobuf is compiled without errors

What did you expect to see?

I did expect to compile protobuf without errors.

What did you see instead?

Anything else we should know about your project / environment?

https://github.com/MarketSquare/robotframework-browser/tree/main/protobuf

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 11
  • Comments: 16 (2 by maintainers)

Most upvoted comments

At least for me pip install --no-binary :all: grpcio --ignore-installed provides workaround for the problem.

pip install --no-binary :all: grpcio --ignore-installed did not work for me. It kept throwing error regarding cygrpc.cpython-39-darwin.so

Installation via conda worked (on Python 3.9):

conda install -c conda-forge grpcio

That did not work for me. I still get

ImportError: dlopen(/opt/homebrew/Caskroom/miniconda/base/envs/python3_9/
lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 0x0002): 
symbol not found in flat namespace '_CFRelease

pip install --no-binary :all: grpcio --ignore-installed did not work for me. It kept throwing error regarding cygrpc.cpython-39-darwin.so

Installation via conda worked (on Python 3.9):

conda install -c conda-forge grpcio

this worked for me as well

Here cause i got the same error.

pip install --no-binary :all: grpcio --ignore-installed worked for me, thanks @aaltat for providing the workaround!

I faced the same issue while importing the “google-ads” package. It internally uses cygrpc.cpython-310-darwin.so

pip install google-ads import -> from google.ads.googleads.client import GoogleAdsClient While building the project i see -

.
.
.
ImportError: dlopen(/Users/souravroy/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so, 2): no suitable image found.  Did find:
	/Users/souravroy/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so: mach-o, but wrong architecture
	/Users/souravroy/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-darwin.so: mach-o, but wrong architecture

For reference -

souravroy@Souravs-MacBook-Air gmads % file $(which python)
/Users/souravroy/bin/python: Mach-O 64-bit executable arm64
souravroy@Souravs-MacBook-Air gmads % 

grpcio version

souravroy@Souravs-MacBook-Air gmads % pip show grpcio
Name: grpcio
Version: 1.43.0
Summary: HTTP/2-based RPC framework
Home-page: https://grpc.io
Author: The gRPC Authors
Author-email: grpc-io@googlegroups.com
License: Apache License 2.0
Location: /Users/souravroy/go/lib/python3.10/site-packages
Requires: six
Required-by: google-ads, google-cloud-bigquery, grpcio-status

python version - Python 3.10.0 I am using M1 chip macbook air.

Any workaround for this issue?

does anyone know similar command for poetry? (or better to say what parameters should I use)

Sorry about this. There seems to be an upstream change to 3.10 tool chain. https://github.com/grpc/grpc/issues/28387

For an immediate solution, Python 3.9 should free of this problem.