skip to Main Content

I’m running a Python application on Ubuntu 22 with Python 3.13.0.

Since upgrading Python from 3.12, I get this error when running the application:

TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'google.cloud.compute.v1.AccessConfig.__firstlineno__'

The application is open source and is here: https://github.com/VerinFast/verinfast

The relevant items from requirements.txt:
google-cloud-compute>=1.14.0

protobuf is not in requirements.txt, but must be installed by another package that is.

The error is triggered by the import of google-cloud-compute:
from google.cloud import compute_v1

So I created a one line file called test.py with this:
from google.cloud import compute_v1

And if I run it with:
python test.py

I get the same long error:

/usr/lib/python3/dist-packages/requests/__init__.py:87: RequestsDependencyWarning: urllib3 (2.2.3) or chardet (5.2.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/home/stconrad/proto_error/test.py", line 1, in <module>
    from google.cloud import compute_v1
  File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/__init__.py", line 21, in <module>
    from .services.accelerator_types import AcceleratorTypesClient
  File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/services/accelerator_types/__init__.py", line 16, in <module>
    from .client import AcceleratorTypesClient
  File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/services/accelerator_types/client.py", line 51, in <module>
    from google.cloud.compute_v1.services.accelerator_types import pagers
  File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/services/accelerator_types/pagers.py", line 41, in <module>
    from google.cloud.compute_v1.types import compute
  File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/types/__init__.py", line 16, in <module>
    from .compute import (
    ...<1496 lines>...
    )
  File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/types/compute.py", line 111135, in <module>
    class ZoneSetPolicyRequest(proto.Message):
    ...<40 lines>...
        )
  File "/home/stconrad/.local/lib/python3.13/site-packages/proto/message.py", line 279, in __new__
    file_info.generate_file_pb(new_class=cls, fallback_salt=full_name)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stconrad/.local/lib/python3.13/site-packages/proto/_file_info.py", line 104, in generate_file_pb
    pool.Add(self.descriptor)
    ~~~~~~~~^^^^^^^^^^^^^^^^^
TypeError: C

From pip show protobuf:

Name: protobuf
Version: 5.28.2
Summary:
Home-page: https://developers.google.com/protocol-buffers/
Author: [email protected]
Author-email: [email protected]
License: 3-Clause BSD License
Location: /home/stconrad/.local/lib/python3.13/site-packages
Requires:
Required-by: google-api-core, google-cloud-compute, google-cloud-monitoring, googleapis-common-protos, grpcio-status, opentelemetry-proto, proto-plus

And pip show google-cloud-compute:

Name: google-cloud-compute
Version: 1.19.2
Summary: Google Cloud Compute API client library
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-compute
Author: Google LLC
Author-email: [email protected]
License: Apache 2.0
Location: /home/stconrad/.local/lib/python3.13/site-packages
Requires: google-api-core, google-auth, proto-plus, protobuf
Required-by: verinfast

So it looks like either google-cloud-compute or protobuf is broken for Python 3.13, which is unfortunate, since it was release October 7.

Looking for a workaround.

I tried wrapping the imports in a try:

try:
    from google.api_core.exceptions import NotFound
    from google.cloud import compute_v1
    from google.cloud.monitoring_v3 import Aggregation, MetricServiceClient, TimeInterval, ListTimeSeriesRequest  # noqa: E501
except:
    print("Google Cloud libraries not imported. Skipping GCP instances.")
    compute_v1 = None
    MetricServiceClient = None
    Aggregation = None
    TimeInterval = None
    ListTimeSeriesRequest = None

Which squashes the error, but then I can’t import Google Cloud data.

2

Answers


  1. This is a known issue that many others have reported as well.

    There seems to be no know workaround other than downgrading Python to 3.12 and waiting for the protobuf devs to fix the issue: https://github.com/protocolbuffers/protobuf/issues/18706

    Login or Signup to reply.
  2. The issue has been fixed with the latest release of protobuf>=5.28.3

    So you just need to reinstall or upgrade.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search