Import Error: cannot import name '_message' M1 macOS
What version of protobuf and what language are you using? Version: 3.17.3 Language: Python - 3.9.11 and 3.9.7
What operating system (Linux, Windows, ...) and version? macOS Monterey 12.5.1, AppleM1 Pro
What runtime / compiler are you using (e.g., python version or gcc version) Python 3.9.11 and Python 3.9.7 What did you do? Steps to reproduce the behavior:
-
Create virtual environment pyenv virtualenv 3.9.11 'env-name' pyenv local 'env-name' pip install --upgrade pip pip install wheel export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="cpp" export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION="2" pip install protobuf==3.17.3
-
pip install --upgrade --force-reinstall protobuf==3.17.3
Collecting protobuf==3.17.3
Using cached protobuf-3.17.3-py2.py3-none-any.whl (173 kB)
Collecting six>=1.9
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
What did you expect to see I am expecting to run without errors
What did you see instead? When I try to run I get the following error:
from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext'
Also '_message.py' file is missing from /google/protobuf/pyext.
I tried the same steps on macOS Big Sur 11.6.8 Intel Core/protobuf 3.17.3/python 3.9.7 and the package installs and there are no errors.
Same issue for me.
Please upgrade to a newer version. Our setup for cross-compiling the binary wheels has been completely rewritten in 4.21.0 and M1 should work properly now.
Strange it was working for me in 3.20.1 and no more for 3.20.2. Maybe it was just an install issue. I fixed the version for now.
Can't upgrade to newer version as grpcio-tools require <4
Ah, sorry I didn't realize this represented a regression from 3.20.1.
An issue has been discovered this morning where none of the binary wheels were released. This is being addressed now.
cc @deannagarcia
My bad I didn't give any more details as the issue was still open. Perfect ! Many thanks.
I believe this should be resolved now. Please re-open if it occurs again.