code-examples icon indicating copy to clipboard operation
code-examples copied to clipboard

Missing pytz dependency in exemple 3-10

Open dsolito opened this issue 2 years ago • 0 comments

Issue description:

Hi Mark, While deploying the Google Cloud Function that uses the google-cloud-bigquery library, I ran into a ModuleNotFoundError for the pytz module. The error message is as follows:

Traceback (most recent call last):
File "/layers/google.python.pip/pip/bin/functions-framework", line 8, in <module>
sys.exit(_cli())
...
ModuleNotFoundError: No module named 'pytz'

The google-cloud-bigquery library appears to depend on the pytz library, but it was not automatically installed along with google-cloud-bigquery.

My requirements.txt file looked like this:

google-cloud-bigquery==2.20.0
google-cloud-logging==2.5.0
pyyaml==5.4.1

Steps to reproduce:

  1. Set up a Google Cloud Function with a requirements.txt file as above.
  2. Deploy the function using the main.py exemple.

Workaround:

Adding pytz explicitly to the requirements.txt file resolved the issue for me:

google-cloud-bigquery==2.20.0
google-cloud-logging==2.5.0
pyyaml==5.4.1
pytz==2021.1

I believe that pytz should be included as a dependency for google-cloud-bigquery to prevent this issue from occurring.

dsolito avatar Jun 26 '23 20:06 dsolito