Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

In python 3.11.0 monitoring_v3 import is failing #517

Closed
fflorez91 opened this issue Dec 20, 2022 · 7 comments
Closed

In python 3.11.0 monitoring_v3 import is failing #517

fflorez91 opened this issue Dec 20, 2022 · 7 comments
Assignees
Labels
api: monitoring Issues related to the googleapis/python-monitoring API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@fflorez91
Copy link

I have followed the steps to install the client library in Python Client for Stackdriver Monitoring API

When trying to run a simple script to list the services, the import fails due to an AttributeError in proto\enums.py file

Environment details

  • OS type and version: Windows 10 Enterprise
  • Python version: Python 3.11.0
  • pip version: pip 22.3.1
  • google-cloud-monitoring version: 2.12.0

Output of pip list:

Package Version


cachetools 5.2.0
certifi 2022.12.7
charset-normalizer 2.1.1
google-api-core 2.11.0
google-auth 2.15.0
google-cloud-appengine-logging 1.2.0
google-cloud-monitoring 2.12.0
googleapis-common-protos 1.57.0
grpcio 1.51.1
grpcio-status 1.51.1
idna 3.4
pip 22.3.1
proto-plus 1.22.1
protobuf 4.21.12

pyasn1 0.4.8
pyasn1-modules 0.2.8
requests 2.28.1
rsa 4.9
setuptools 65.6.3
six 1.16.0
urllib3 1.26.13
wheel 0.38.4

Steps to reproduce

  1. Try to run a python script importing monitoring_v3

Code example

from google.cloud import monitoring_v3

Stack trace

Traceback (most recent call last):
File "...\list_services.py", line 1, in
from google.cloud import monitoring_v3
File "...\Lib\site-packages\google\cloud\monitoring_v3_init_.py", line 16, in
from google.cloud.monitoring import gapic_version as package_version
File "...\Lib\site-packages\google\cloud\monitoring_init_.py", line 21, in
from google.cloud.monitoring_v3.services.alert_policy_service.client import (
File "...\Lib\site-packages\google\cloud\monitoring_v3\services\alert_policy_service_init_.py", line 16, in
from .client import AlertPolicyServiceClient
File "...\Lib\site-packages\google\cloud\monitoring_v3\services\alert_policy_service\client.py", line 49, in
from google.cloud.monitoring_v3.services.alert_policy_service import pagers
File "...\Lib\site-packages\google\cloud\monitoring_v3\services\alert_policy_service\pagers.py", line 27, in
from google.cloud.monitoring_v3.types import alert
File "...\Lib\site-packages\google\cloud\monitoring_v3\types_init_.py", line 16, in
from .alert import (
File "...\Lib\site-packages\google\cloud\monitoring_v3\types\alert.py", line 20, in
from google.cloud.monitoring_v3.types import common
File "...\Lib\site-packages\google\cloud\monitoring_v3\types\common.py", line 50, in
class ServiceTier(proto.Enum):
File "...\Lib\site-packages\proto\enums.py", line 61, in new
idx = attrs._member_names.index(pb_options)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'index'

@product-auto-label product-auto-label bot added the api: monitoring Issues related to the googleapis/python-monitoring API. label Dec 20, 2022
@eremeevfd
Copy link

Facing this issue as well

@eremeevfd
Copy link

I've found code in proto/enums.py:ProtoEnumMeta.__new__:

        if pb_options in attrs._member_names:
            idx = attrs._member_names.index(pb_options)
            attrs._member_names.pop(idx)

According to error and code, it looks like it was a list and now it's a dict, so we can fix it this way:

        if pb_options in attrs._member_names:
            attrs._member_names.pop(pb_options, None)

However, I still can't figure which package is it exactly

@eremeevfd
Copy link

It's a proto-plus package

@eremeevfd
Copy link

googleapis/proto-plus-python#326

There is even better fix there

@parthea
Copy link
Contributor

parthea commented Jan 5, 2023

Thanks for reporting this issue. I've published a pre-release version of proto-plus with the fix. https://pypi.org/project/proto-plus/1.22.2rc1/

The release will be published on Monday
googleapis/proto-plus-python#343

@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 5, 2023
@parthea parthea self-assigned this Jan 5, 2023
@eremeevfd
Copy link

@parthea Great! Thank you very much!

@parthea
Copy link
Contributor

parthea commented Feb 15, 2023

Closing as obsolete

@parthea parthea closed this as completed Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: monitoring Issues related to the googleapis/python-monitoring API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants