gRPC Python - Mac M1 (arm64) - Issue running grpcio-tools

6,199 views
Skip to first unread message

Amit Saha

unread,
Jan 14, 2022, 1:22:32 AM1/14/22
to grpc.io
Hi all,

I installed grpcio-tools using the poetry python packager using poetry
add grpcio-tools. I have verified it's the same issue described below
if I use pip directly.

When trying to use grpcio-tools on Python 3.10 - Mac M1, I am running
into this error when generating some Python code:

% poetry run python -m grpc_tools.protoc --python_out=.
--grpc_python_out=. user_sessions.proto
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py",
line 86, in _run_code
exec(code, run_globals)
File "/Users/echorand/Library/Caches/pypoetry/virtualenvs/user-sessions-2yjUCcPI-py3.10/lib/python3.10/site-packages/grpc_tools/protoc.py",
line 20, in <module>
from grpc_tools import _protoc_compiler
ImportError: dlopen(/Users/echorand/Library/Caches/pypoetry/virtualenvs/user-sessions-2yjUCcPI-py3.10/lib/python3.10/site-packages/grpc_tools/_protoc_compiler.cpython-310-darwin.so,
0x0002): tried:
'/Users/echorand/Library/Caches/pypoetry/virtualenvs/user-sessions-2yjUCcPI-py3.10/lib/python3.10/site-packages/grpc_tools/_protoc_compiler.cpython-310-darwin.so'
(mach-o file, but is an incompatible architecture (have 'x86_64', need
'arm64e')), '/usr/lib/_protoc_compiler.cpython-310-darwin.so' (no such
file)

I tried this next:

% arch -x86_64 poetry run python -m grpc_tools.protoc --proto_path .
--python_out=. --grpc_python_out=. user_sessions.proto

And that works. So, perhaps an issue with the universal binary wheel
of grpcio-tools I am using and it's non compatibility with arm64?

Thanks,
Amit.

Lidi Zheng

unread,
Jan 14, 2022, 12:29:21 PM1/14/22
to grpc.io
Yes, there is an issue tracking this bug: https://github.com/grpc/grpc/issues/28387.

So far, this issue only presents on Python 3.10.

Amit Saha

unread,
Jan 15, 2022, 10:05:46 PM1/15/22
to grpc.io
On Saturday, January 15, 2022 at 4:29:21 AM UTC+11 Lidi Zheng wrote:
Yes, there is an issue tracking this bug: https://github.com/grpc/grpc/issues/28387.

So far, this issue only presents on Python 3.10.

Thank you. I have commented on the ticket to put up my hand in helping debug this with some help from you.
Reply all
Reply to author
Forward
0 new messages