Failed to import wandb after updating to wandb 0.16.6

Hello, I can’t do import wandb and got following error after upgrading to wandb 0.16.6. My first guess is incompatibility of protobuf, but don’t know how to fix. My python version is 3.11. Please help, thank you.

Traceback (most recent call last):
  File "/app/cli.py", line 10, in <module>
    import wandb
  File "/venv/lib/python3.11/site-packages/wandb/__init__.py", line 27, in <module>
    from wandb import sdk as wandb_sdk
  File "/venv/lib/python3.11/site-packages/wandb/sdk/__init__.py", line 25, in <module>
    from .artifacts.artifact import Artifact
  File "/venv/lib/python3.11/site-packages/wandb/sdk/artifacts/artifact.py", line 46, in <module>
    from wandb.apis.normalize import normalize_exceptions
  File "/venv/lib/python3.11/site-packages/wandb/apis/__init__.py", line 43, in <module>
    from .internal import Api as InternalApi  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/wandb/apis/internal.py", line 3, in <module>
    from wandb.sdk.internal.internal_api import Api as InternalApi
  File "/venv/lib/python3.11/site-packages/wandb/sdk/internal/internal_api.py", line 48, in <module>
    from ..lib import retry
  File "/venv/lib/python3.11/site-packages/wandb/sdk/lib/retry.py", line 17, in <module>
    from .mailbox import ContextCancelledError
  File "/venv/lib/python3.11/site-packages/wandb/sdk/lib/mailbox.py", line 102, in <module>
    class _MailboxSlot:
  File "/venv/lib/python3.11/site-packages/wandb/sdk/lib/mailbox.py", line 103, in _MailboxSlot
    _result: Optional[pb.Result]
                      ^^^^^^^^^
AttributeError: module 'wandb.proto.wandb_internal_pb2' has no attribute 'Result'
(.venv) ching-yi@Ching-Yis-MacBook-Pro morphio % docker compose run --rm main python cli.py eval --help
Traceback (most recent call last):
  File "/app/cli.py", line 10, in <module>
    import wandb
  File "/venv/lib/python3.11/site-packages/wandb/__init__.py", line 27, in <module>
    from wandb import sdk as wandb_sdk
  File "/venv/lib/python3.11/site-packages/wandb/sdk/__init__.py", line 25, in <module>
    from .artifacts.artifact import Artifact
  File "/venv/lib/python3.11/site-packages/wandb/sdk/artifacts/artifact.py", line 46, in <module>
    from wandb.apis.normalize import normalize_exceptions
  File "/venv/lib/python3.11/site-packages/wandb/apis/__init__.py", line 43, in <module>
    from .internal import Api as InternalApi  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/wandb/apis/internal.py", line 3, in <module>
    from wandb.sdk.internal.internal_api import Api as InternalApi
  File "/venv/lib/python3.11/site-packages/wandb/sdk/internal/internal_api.py", line 48, in <module>
    from ..lib import retry
  File "/venv/lib/python3.11/site-packages/wandb/sdk/lib/retry.py", line 17, in <module>
    from .mailbox import ContextCancelledError
  File "/venv/lib/python3.11/site-packages/wandb/sdk/lib/mailbox.py", line 102, in <module>
    class _MailboxSlot:
  File "/venv/lib/python3.11/site-packages/wandb/sdk/lib/mailbox.py", line 103, in _MailboxSlot
    _result: Optional[pb.Result]
                      ^^^^^^^^^
AttributeError: module 'wandb.proto.wandb_internal_pb2' has no attribute 'Result'

Thank you so much for writing in, and apologies you are seeing this behavior.

AttributeError: module 'wandb.proto.wandb_internal_pb2' has no attribute 'Result'" - this error does seem to be coming from the protobuf version. Would you be able to try to downgrade your protobuf package to 3.20.x or lower?

Thank you for the reply! I’m using protobuf==4.25.3, which is automatically pinned by wandb. I used pip-compile --generate-hashes --no-emit-index-url --strip-extras requirements.dev.in, and that generated requirements.dev.text exactly:

...
protobuf==4.25.3 \
    --hash=sha256:19b270aeaa0099f16d3ca02628546b8baefe2955bbe23224aaf856134eccf1e4 \
    --hash=sha256:209ba4cc916bab46f64e56b85b090607a676f66b473e6b762e6f1d9d591eb2e8 \
    --hash=sha256:25b5d0b42fd000320bd7830b349e3b696435f3b329810427a6bcce6a5492cc5c \
    --hash=sha256:7c8daa26095f82482307bc717364e7c13f4f1c99659be82890dcfc215194554d \
    --hash=sha256:c053062984e61144385022e53678fbded7aea14ebb3e0305ae3592fb219ccfa4 \
    --hash=sha256:d4198877797a83cbfe9bffa3803602bbe1625dc30d8a097365dbc762e5790faa \
    --hash=sha256:e3c97a1555fd6388f857770ff8b9703083de6bf1f9274a002a332d65fbb56c8c \
    --hash=sha256:e7cb0ae90dd83727f0c0718634ed56837bfeeee29a5f82a7514c03ee1364c019 \
    --hash=sha256:f0700d54bcf45424477e46a9f0944155b46fb0639d69728739c0e47bab83f2b9 \
    --hash=sha256:f1279ab38ecbfae7e456a108c5c0681e4956d5b1090027c1de0f934dfdb4b35c \
    --hash=sha256:f4f118245c4a087776e0a8408be33cf09f6c547442c00395fbfb116fac2f8ac2
    # via wandb
...

from requirements.dev.in:

-c requirements.txt
black>=24.3.0
cfn-lint>=0.86.2
cfn-lint-ax>=0.0.13
cfn-lint-serverless>=0.3.2
docker>=7.0.0
flake8>=7.0.0
httpx>=0.27.0
mypy>=1.9.0
iac-container>=2023.8.17
isort>=5.13.2
pandas>=2.2.1
pytest>=8.1.1
troposphere>=4.7.0
wandb>=0.16.6
yamllint>=1.35.1

I didn’t have this problem before, so it is super confusing now…

Thank you for sending it over!

Could you try running pip install protobuf==3.20.1 and see if that changes anything for you?

Could you also see if downgrading back to 0.16.5 resolves this concern for you, and its definitely something to do with 0.16.6?

1 Like

Do you mean protobuf==3.20.1 and wandb==0.16.5 simultaneously? I have tried wandb==0.16.5 and the error still exists. The version of protobuf is pinned by wandb, so I am unsure how to set protobuf==3.20.1 for wandb==0.16.5 manually …

Could you try running pip install protobuf==3.20.1?

It should install 3.20.1 to your current enviroment.

Hi there, I wanted to follow up on this request. Please let us know if we can be of further assistance or if your issue has been resolved.

Hi, since we have not heard back from you, we are going to close this request. If you would like to reopen the conversation, please let us know! Unfortunately, at the moment, we do not receive notifications if a thread reopens on Discourse. So, please feel free to create a new ticket regarding your concern if you’d like to continue the conversation.