После обновления Python с версии 3.12 я получаю следующую ошибку при запуске приложения:
Код: Выделить всё
TypeError: Couldn't build proto file into descriptor pool: duplicate symbol 'google.cloud.compute.v1.AccessConfig.__firstlineno__'
Соответствующие элементы из файла require.txt:
Код: Выделить всё
google-cloud-compute>=1.14.0
Ошибка вызвана импорт google-cloud-compute:
Код: Выделить всё
from google.cloud import compute_v1
Код: Выделить всё
from google.cloud import compute_v1
Код: Выделить всё
python test.py
Код: Выделить всё
/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
from google.cloud import compute_v1
File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/__init__.py", line 21, in
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
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
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
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
from .compute import (
......
)
File "/home/stconrad/.local/lib/python3.13/site-packages/google/cloud/compute_v1/types/compute.py", line 111135, in
class ZoneSetPolicyRequest(proto.Message):
......
)
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
Код: Выделить всё
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
Код: Выделить всё
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
Ищу обходной путь.
Я попробовал обернуть импорт:
Код: Выделить всё
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
Подробнее здесь: https://stackoverflow.com/questions/791 ... e-cloud-co