Skip to content

ImportError with Python 3.9 #7978

@jcugat

Description

@jcugat

What version of protobuf and what language are you using?
Version: 3.13.0
Language: Python

What operating system (Linux, Windows, ...) and version?
Docker container with Debian GNU/Linux 10 (buster)

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

What did you do?
Python 3.8 works as expected:

$ docker run -it python:3.8 bash
root@9368d8cf9ab0:/# pip install protobuf
Collecting protobuf
  Downloading protobuf-3.13.0-cp38-cp38-manylinux1_x86_64.whl (1.3 MB)
     |████████████████████████████████| 1.3 MB 524 kB/s
Requirement already satisfied: setuptools in /usr/local/lib/python3.8/site-packages (from protobuf) (50.3.2)
Collecting six>=1.9
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, protobuf
Successfully installed protobuf-3.13.0 six-1.15.0
root@9368d8cf9ab0:/# PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="cpp" python -c 'from google.protobuf import descriptor'
root@9368d8cf9ab0:/# echo $?
0
root@9368d8cf9ab0:/# exit

But Python 3.9 fails the same import:

$ docker run -it python:3.9 bash
root@5966444c1878:/# pip install protobuf
Collecting protobuf
  Downloading protobuf-3.13.0-py2.py3-none-any.whl (438 kB)
     |████████████████████████████████| 438 kB 522 kB/s
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (from protobuf) (50.3.2)
Collecting six>=1.9
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: six, protobuf
Successfully installed protobuf-3.13.0 six-1.15.0
root@5966444c1878:/# PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="cpp" python -c 'from google.protobuf import descriptor'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 48, in <module>
    from google.protobuf.pyext import _message
ImportError: cannot import name '_message' from 'google.protobuf.pyext' (/usr/local/lib/python3.9/site-packages/google/protobuf/pyext/__init__.py)
root@5966444c1878:/# echo $?
1
root@5966444c1878:/# python -V
Python 3.9.0
root@5966444c1878:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

What did you expect to see
Import should work just like with previous versions.

What did you see instead?
An import error.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions