Skip to content

Missing pytz dependency #468

@tomwphillips

Description

@tomwphillips

Environment details

  • OS type and version: macOS 11.4
  • Python version: 3.8.2
  • pip version: 21.1.3
  • google-cloud-pubsub version: 2.7.0

Steps to reproduce

  1. Install google-cloud-pubsub, e.g. pipenv install --python 3.8 google-cloud-pubsub.
  2. Run code below.

Code example

from concurrent.futures import TimeoutError
from typing import Callable

from google.cloud.pubsub_v1 import SubscriberClient
from google.cloud.pubsub_v1.types import PubsubMessage


def process_messages(
    project_id: str,
    subscription_id: str,
    callback: Callable[[PubsubMessage], None],
    timeout: int = 5,
) -> None:
    subscriber = SubscriberClient()
    subscription_path = subscriber.subscription_path(project_id, subscription_id)
    streaming_pull_future = subscriber.subscribe(subscription_path, callback=callback)
    with subscriber:
        try:
            streaming_pull_future.result(timeout=timeout)
        except TimeoutError:
            streaming_pull_future.cancel()  # Trigger the shutdown.
            streaming_pull_future.result()  # Block until the shutdown is complete.


if __name__ == "__main__":
    process_messages("my-project", "my-sub")

Stack trace

Traceback (most recent call last):
  File "loaders.py", line 4, in <module>
    from google.cloud.pubsub_v1 import SubscriberClient
  File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/__init__.py", line 19, in <module>
    from google.cloud.pubsub_v1 import subscriber
  File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/__init__.py", line 17, in <module>
    from google.cloud.pubsub_v1.subscriber.client import Client
  File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/client.py", line 26, in <module>
    from google.cloud.pubsub_v1.subscriber._protocol import streaming_pull_manager
  File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py", line 35, in <module>
    import google.cloud.pubsub_v1.subscriber.message
  File "/Users/tomphillips/.local/share/virtualenvs/loaders-emkxO8nx/lib/python3.8/site-packages/google/cloud/pubsub_v1/subscriber/message.py", line 20, in <module>
    import pytz
ModuleNotFoundError: No module named 'pytz'

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubIssues related to the googleapis/python-pubsub API.type: questionRequest for information or clarification. Not an issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions