GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — error: Module "google.cloud" has no attribute "pubsub_v1" · Issue #1059 · googleapis/python-pubsub

This repository was archived by the owner on Oct 13, 2026. It is now read-only.
This repository was archived by the owner on Oct 13, 2026. It is now read-only.

error: Module "google.cloud" has no attribute "pubsub_v1" #1059

Copy link
Copy link
Closed
#1186
Closed
error: Module "google.cloud" has no attribute "pubsub_v1"#1059
#1186
Copy link
Assignees
mukund-ananthu
Labels
api: pubsubIssues related to the googleapis/python-pubsub API.

Description

@coactive-jeffrey
coactive-jeffrey
opened on Jan 11, 2024
Issue body actions

python-pubsub/samples/snippets/subscriber.py

Line 35 in 265f410

from google.cloud import pubsub_v1

Steps to Reproduce:

  1. cd python-pubsub/samples/snippets
  2. python3 -m venv venv && source ./venv/bin/activate
  3. pip install -r requirements.txt
  4. python3 -m pip install mypy
  5. python3 -m mypy --install-types
  6. python3 -m mypy subscriber.py
  7. Observe many occurrences of error: Module "google.cloud" has no attribute "pubsub_v1" [attr-defined]

Activity

  1. blunderbuss-gcf
    assigned
    pradn
    on Jan 11, 2024
  2. product-auto-label
    added
    api: pubsubIssues related to the googleapis/python-pubsub API.
    on Jan 11, 2024
  3. parthea commented on Jan 11, 2024

    @parthea
    parthea
    on Jan 11, 2024
    Contributor
    More actions

    Hi @coactive-jeffrey,

    Thanks for providing the detailed reproduction steps. I wasn't able to re-create the same error error: Module "google.cloud" has no attribute "pubsub_v1", however there is an open issue to address a mypy issue with google.cloud.pubsub_v1. See googleapis/google-cloud-python#15652. Since I wasn't able to create the error error: Module "google.cloud" has no attribute "pubsub_v1" , I also wonder if this could be an environment specific issue.

    Following the steps that you provided, I have the following output

    (venv) (base) root@b76d9c22dce0:/python-pubsub/samples/snippets# python3 -m mypy subscriber.py
    subscriber.py:35: error: Skipping analyzing "google.cloud": module is installed, but missing library stubs or py.typed marker  [import-untyped]
    subscriber.py:107: error: Skipping analyzing "google.cloud.pubsub_v1.types": module is installed, but missing library stubs or py.typed marker  [import-untyped]
    subscriber.py:107: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
    subscriber.py:363: error: Library stubs not installed for "google.protobuf"  [import-untyped]
    subscriber.py:363: note: Hint: "python3 -m pip install types-protobuf"
    subscriber.py:363: note: (or run "mypy --install-types" to install all missing stub packages)
    subscriber.py:537: error: Returning Any from function declared to return "Subscription"  [no-any-return]
    subscriber.py:582: error: Returning Any from function declared to return "Subscription"  [no-any-return]
    subscriber.py:765: error: Skipping analyzing "google.cloud.pubsub_v1.subscriber": module is installed, but missing library stubs or py.typed marker  [import-untyped]
    Found 6 errors in 1 file (checked 1 source file)
    

    After installing types-protobuf as suggested by the hint, the "google.protobuf" specific error was resolved.
    I used pip install "types-protobuf==4.24.0.4" (I'm not using the latest version of types-protobuf as there is an open issue related to it python/typeshed#11254 )

    The mypy failures also reduced if you use mypy==0.910 which is the version in noxfile.py. I've opened a bug for the team to update to a newer version of mypy: #1061

    (venv) (base) root@b76d9c22dce0:/python-pubsub/samples/snippets# python3 -m mypy subscriber.py
    subscriber.py:35: error: Skipping analyzing "google.cloud": found module but no type hints or library stubs
    subscriber.py:35: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
    subscriber.py:107: error: Skipping analyzing "google.cloud.pubsub_v1.types": found module but no type hints or library stubs
    subscriber.py:363: error: Library stubs not installed for "google.protobuf" (or incompatible with Python 3.10)
    subscriber.py:363: note: Hint: "python3 -m pip install types-protobuf"
    subscriber.py:363: note: (or run "mypy --install-types" to install all missing stub packages)
    subscriber.py:537: error: Returning Any from function declared to return "Subscription"
    subscriber.py:582: error: Returning Any from function declared to return "Subscription"
    subscriber.py:765: error: Skipping analyzing "google.cloud.pubsub_v1.subscriber": found module but no type hints or library stubs
    Found 6 errors in 1 file (checked 1 source file)
    

    I found more mypy error messages when I run the command from the root of the repository. It looks like the mypy presubmit checks are not currently running for the samples files. I've opened googleapis/google-cloud-python#15646 for the team to take a look.

    (venv) (base) root@b76d9c22dce0:/python-pubsub# python3 -m mypy samples/snippets/subscriber.py
    samples/snippets/subscriber.py:107: error: Module "google.cloud.pubsub_v1.types" has no attribute "DeadLetterPolicy"
    samples/snippets/subscriber.py:172: error: Module has no attribute "PushConfig"
    samples/snippets/subscriber.py:208: error: Module has no attribute "PushConfig"
    samples/snippets/subscriber.py:209: error: Module has no attribute "PushConfig"
    samples/snippets/subscriber.py:337: error: Module has no attribute "BigQueryConfig"
    samples/snippets/subscriber.py:375: error: Module has no attribute "CloudStorageConfig"
    samples/snippets/subscriber.py:384: error: Module has no attribute "CloudStorageConfig"
    samples/snippets/subscriber.py:454: error: Module has no attribute "PushConfig"
    samples/snippets/subscriber.py:456: error: Module has no attribute "Subscription"
    samples/snippets/subscriber.py:484: error: Module "google.cloud.pubsub_v1.types" has no attribute "DeadLetterPolicy"
    samples/snippets/subscriber.py:484: error: Module "google.cloud.pubsub_v1.types" has no attribute "FieldMask"
    samples/snippets/subscriber.py:524: error: Module has no attribute "Subscription"
    samples/snippets/subscriber.py:546: error: Module "google.cloud.pubsub_v1.types" has no attribute "FieldMask"
    samples/snippets/subscriber.py:571: error: Module has no attribute "Subscription"
    samples/snippets/subscriber.py:843: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior
    samples/snippets/subscriber.py:915: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior
    samples/snippets/subscriber.py:922: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior
    Found 17 errors in 1 file (checked 1 source file)
    
  4. parthea commented on Jan 11, 2024

    @parthea
    parthea
    on Jan 11, 2024
    Contributor
    More actions

    cc @michaelpri10

  5. michaelpri10 commented on Jan 31, 2024

    @michaelpri10
    michaelpri10
    on Jan 31, 2024
    Contributor
    More actions

    cc @mukund-ananthu

  6. parthea
    assigned
    mukund-ananthu
    and unassigned
    pradn
    on Jan 31, 2024
  7. mukund-ananthu
    closed this as completedin #1186on Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mukund-ananthu
    mukund-ananthu

Labels

api: pubsubIssues related to the googleapis/python-pubsub API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.