Description
What version of protobuf and what language are you using?
Versions: 3.17.3
, 3.18.0
, 3.18.1
, and 3.19.0
Language: Python (versions 3.7.2
, 3.8.6
, 3.9.0
, and 3.10.0
What operating system (Linux, Windows, ...) and version? gLinux
What runtime / compiler are you using (e.g., python version or gcc version) python and/or cpp
What did you do?
Steps to reproduce the behavior:
Run this bash script. Note that it require pyenv
to be installed, along with Python versions 3.7.2
.
#!/bin/bash
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
pyenv global 3.7.2
python -mvenv /tmp/venv
. /tmp/venv/bin/activate
python -m pip install protobuf==3.19.0
python -c "from google.protobuf import descriptor_pb2"
What did you expect to see
I expect this script to run without error.
What did you see instead?
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/venv/lib/python3.7/site-packages/google/protobuf/descriptor_pb2.py", line 5, in <module>
from google.protobuf import descriptor as _descriptor
File "/tmp/venv/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext' (/tmp/venv/lib/python3.7/site-packages/google/protobuf/pyext/__init__.py)
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
This was first detected as a performance issue, as our benchmarks began showing large regressions due to the library unknowingly running the python
implementation. For more context on the history see this Issue.
Anything else we should know about your project / environment
There are issues with a number of combinations of Python versions and protobuf
library versions. Here are the combinations I found that have problems when running the above reproduction script:
Python version | Protobuf version | Env var status | Result |
---|---|---|---|
3.7.2 | 3.19.0 | unset | defaults to python implementation incorrectly |
3.7.2 | 3.19.0 | cpp |
results in above error |
3.7.2 | 3.18.1 | unset | defaults to python implementation incorrectly |
3.10.0 | 3.18.1 | unset | defaults to python implementation incorrectly |
3.7.2 | 3.18.1 | cpp |
results in above error |
3.10.0 | 3.18.1 | cpp |
results in above error |
3.7.2 | 3.18.0 | unset | defaults to python implementation incorrectly |
3.10.0 | 3.18.0 | unset | defaults to python implementation incorrectly |
3.7.2 | 3.18.0 | cpp |
results in above error |
3.10.0 | 3.18.0 | cpp |
results in above error |
3.10.0 | 3.17.3 | unset | defaults to python implementation incorrectly |
3.10.0 | 3.17.3 | cpp |
results in above error |