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

Python - Mac M1 - ImportError: cannot import name '_message' from 'google.protobuf.pyext' #12164

Closed
Laurens-T opened this issue Mar 7, 2023 · 1 comment
Assignees

Comments

@Laurens-T
Copy link

What version of protobuf and what language are you using?
Version: 4.22 (but I have the same issue with 3.20.3)
Language: Python

What operating system (Linux, Windows, ...) and version?
MacOS Ventura 13.2.1, Apple M1 Pro

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.11 (or any python version from 3.7-3.11)

gcc:

Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

What did you do?

➜  python --version
Python 3.11.0

➜  python -m venv venv
➜  source venv/bin/activate

(venv) ➜  pip install -U pip protobuf
Collecting protobuf
  Downloading protobuf-4.22.0-cp37-abi3-macosx_10_9_universal2.whl (397 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 397.2/397.2 kB 2.6 MB/s eta 0:00:00
Installing collected packages: protobuf
Successfully installed protobuf-4.22.0

[notice] A new release of pip available: 22.3 -> 23.0.1
[notice] To update, run: pip install --upgrade pip

(venv) ➜  python -c "from google.protobuf.pyext import _message"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'google.protobuf.pyext._message'

What did you expect to see
A successful import.

What did you see instead?
ImportError: cannot import name '_message' from 'google.protobuf.pyext'

Anything else we should know about your project / environment
No

Previous issue
It is basically the same issue as I had 2 years ago: #8820.

The workarounds in that issue do still work.

@Laurens-T Laurens-T added the untriaged auto added to all issues by default when created. label Mar 7, 2023
@fowles fowles added python 22.x and removed untriaged auto added to all issues by default when created. labels Mar 16, 2023
@haberman
Copy link
Member

haberman commented May 2, 2023

This is expected. As of release 4.21.x we no longer ship the google.protobuf.pyext._message module. The native module is now google._upb._message. More info here: https://github.com/protocolbuffers/protobuf/tree/main/python#implementation-backends

But users should not be directly importing any of the private modules (ones beginning with an underscore).

@haberman haberman closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants