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 — Can't import google.protobuf.timestamp_pb2 from App Engine · Issue #1436 · googleapis/google-cloud-python

Can't import google.protobuf.timestamp_pb2 from App Engine #1436

New issue
Copy link
New issue
Copy link
Closed
Closed
Can't import google.protobuf.timestamp_pb2 from App Engine#1436
Copy link
Assignees
theacodes
Labels
packaging

Description

@barakcoh
barakcoh
opened on Feb 1, 2016
Issue body actions

I'm getting ImportError: No module named protobuf from the line from google.protobuf import timestamp_pb2 because the google module refers to the AppEngine SDK.

This is a well-known issue that's been around for years. Maybe you can bundle protobuf directly inside gcloud-python instead of an external dependency?

Activity

Next
  1. dhermes
    added
    packaging
    on Feb 1, 2016
  2. dhermes commented on Feb 1, 2016

    @dhermes
    dhermes
    on Feb 1, 2016
    Contributor
    More actions

    Thanks for reporting and for upgrading!

    I am curious about a few things:

    1. How do you vendor in gcloud-python for App Engine?
    2. Do you vendor in protobuf? (AFAIK it isn't part of the GAE runtime)
    3. Which services / gcloud-python subpackages do you use? (I'm curious which imports / import paths your code has been using.)
    4. Are you modify the gcloud module object so that it acts like a namespace package? If no, this is the solution to your problem. I made an app that shows how to do this. The app is now out-of-date but the file that handles protobuf imports is still valid.
  3. theacodes commented on Feb 1, 2016

    @theacodes
    theacodes
    on Feb 1, 2016
    Contributor
    More actions

    Are you modify the gcloud module object so that it acts like a namespace package? If no, this is the solution to your problem. I made an app that shows how to do this. The app is now out-of-date but the file that handles protobuf imports is still valid.

    I don't think this shouldn't be necessary anymore, I'm interested to see if that's somehow changed.

  4. dhermes commented on Feb 1, 2016

    @dhermes
    dhermes
    on Feb 1, 2016
    Contributor
    More actions

    Me too. Thanks for chiming in @jonparrott I was going to ping you.

  5. theacodes commented on Feb 1, 2016

    @theacodes
    theacodes
    on Feb 1, 2016
    Contributor
    More actions

    I should really write an App Engine test case.

  6. dhermes commented on Feb 9, 2016

    @dhermes
    dhermes
    on Feb 9, 2016
    Contributor
    More actions

    @SaMnCo also reported this import error, it may be

    • we don't understand our requirements like we think we do.
    • pip doesn't upgrade deps in setup.py as I expect
    • a PYTHONPATH issue
  7. dhermes commented on Feb 11, 2016

    @dhermes
    dhermes
    on Feb 11, 2016
    Contributor
    More actions

    @SaMnCo can you do a pip show protobuf, pip show gcloud in the environment where this is failing and then make sure the same versions are imported:

    $ python -c 'import google.protobuf; print(google.protobuf.__version__)'
    $ python -c 'import gcloud; print(gcloud.__version__)'
  8. kvdb commented on Feb 18, 2016

    @kvdb
    kvdb
    on Feb 18, 2016
    More actions

    @dhermes I think I've got a similar problem as the reporter of the issue. Perhaps I can help by providing my answers to your questions:

    How do you vendor in gcloud-python for App Engine?

    In appengine_config.py:

    from google.appengine.ext import vendor                                         
    vendor.add('libs')                                                              
    import google.protobuf; print(google.protobuf.__version__)                      
    import gcloud; print(gcloud.__version__) 
    

    Results in:

    3.0.0b2
    0.10.0
    

    Do you vendor in protobuf? (AFAIK it isn't part of the GAE runtime)

    It's in libs, so yes.

    Which services / gcloud-python subpackages do you use? (I'm curious which imports / import paths your code has been using.)

      from gcloud import storage
    File "/x/libs/gcloud/storage/__init__.py", line 43, in <module>
      from gcloud.storage.blob import Blob
    File "/x/libs/gcloud/storage/blob.py", line 27, in <module>
      from gcloud._helpers import _rfc3339_to_datetime
    File "/x/libs/gcloud/_helpers.py", line 26, in <module>
      from google.protobuf import timestamp_pb2
    ImportError: No module named protobuf
    
  9. dhermes commented on Feb 18, 2016

    @dhermes
    dhermes
    on Feb 18, 2016
    Contributor
    More actions

    @kvdb Thanks a lot. I'm wondering now if it may be related to Darth-Vendor and namespace packages not being the best of friends. I need to dig in and reproduce. Can you confirm that's what you used to vendor in your package?

  10. theacodes commented on Feb 18, 2016

    @theacodes
    theacodes
    on Feb 18, 2016
    Contributor
    More actions

    Darth is part of the SDK (from google.appengine.ext import vendor) so that's definitely what's being used. It explicitly has support for namespaces. So I'm also unsure what's going on.

  11. dhermes commented on Feb 19, 2016

    @dhermes
    dhermes
    on Feb 19, 2016
    Contributor
    More actions

    Maybe it's an issue with old versions of pip? The module certainly shows up:

    $ mkdir lib
    $ pip install -t lib gcloud
    $ cd lib/google/protobuf/
    $ ls -1 *pb2.py | egrep -v unittest
    any_pb2.py
    api_pb2.py
    descriptor_pb2.py
    duration_pb2.py
    empty_pb2.py
    field_mask_pb2.py
    source_context_pb2.py
    struct_pb2.py
    timestamp_pb2.py
    type_pb2.py
    wrappers_pb2.py
    

    Going to run a test app in dev_appserver to verify import works.

  12. dhermes commented on Feb 19, 2016

    @dhermes
    dhermes
    on Feb 19, 2016
    Contributor
    More actions

    OK I just confirmed this works in dev_appserver as well.

    @kvdb Have you tried clearing out lib and starting fresh? What version of pip are you using?

  13. dhermes
    changed the title [-]AppEngine support broken in 0.9.0[/-] [+]Can't import google.protobuf.timestamp_pb2 from App Engine[/+] on Feb 20, 2016
  14. kvdb commented on Feb 21, 2016

    @kvdb
    kvdb
    on Feb 21, 2016
    More actions

    pip 8.0.2
    Yes, I cleared my virtualenv/libs before reporting.

  15. dhermes commented on Feb 21, 2016

    @dhermes
    dhermes
    on Feb 21, 2016
    Contributor
    More actions

    Very strange! Does the timestamp_pb2.py file exist and just the import fails or the file never shows up?

  16. 62 remaining items

  17. yanik-ai commented on Sep 5, 2016

    @yanik-ai
    yanik-ai
    on Sep 5, 2016
    More actions

    @tseaver, @jonparrott installing it with pip put the package in the wrong directory.
    And appengine expects it in its own directory google_appengine/google.

  18. theacodes commented on Sep 6, 2016

    @theacodes
    theacodes
    on Sep 6, 2016
    Contributor
    More actions

    @yanikkoval can you give us more details? What exact pip command are you running? What's in your appengine_config.py?

  19. ensonic commented on Feb 21, 2017

    @ensonic
    ensonic
    on Feb 21, 2017
    More actions

    It is also happening on local machine using Ubuntu 14.04 LTS - from pip freze:

    gapic-google-cloud-datastore-v1==0.14.1
    gapic-google-cloud-logging-v2==0.90.1
    gapic-google-cloud-pubsub-v1==0.14.1
    gcloud==0.18.3
    google-cloud==0.22.0
    google-cloud-bigquery==0.22.1
    google-cloud-bigtable==0.22.0
    google-cloud-core==0.22.1
    google-cloud-datastore==0.22.1
    google-cloud-dns==0.22.0
    google-cloud-error-reporting==0.22.0
    google-cloud-happybase==0.22.0
    google-cloud-language==0.22.2
    google-cloud-logging==0.22.0
    google-cloud-monitoring==0.22.0
    google-cloud-pubsub==0.22.0
    google-cloud-resource-manager==0.22.0
    google-cloud-runtimeconfig==0.22.0
    google-cloud-storage==0.22.0
    google-cloud-translate==0.22.0
    google-cloud-vision==0.22.0
    grpc-google-cloud-datastore-v1==0.14.0
    grpc-google-cloud-logging-v2==0.90.0
    grpc-google-cloud-pubsub-v1==0.14.0
    
    Traceback (most recent call last):
      File "./src/main.py", line 9, in <module>
        from google.cloud import logging, pubsub
      File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/__init__.py", line 18, in <module>
        from google.cloud.logging.client import Client
      File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/client.py", line 32, in <module>
        from google.cloud.client import JSONClient
      File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 21, in <module>
        from google.cloud._helpers import _determine_default_project
      File "/usr/local/lib/python2.7/dist-packages/google/cloud/_helpers.py", line 30, in <module>
        from google.protobuf import timestamp_pb2
    ImportError: cannot import name timestamp_pb2
    
  20. dhermes commented on Feb 21, 2017

    @dhermes
    dhermes
    on Feb 21, 2017
    Contributor
    More actions

    @ensonic Run import google; print(google.__path__) so see what the problem is. The usual suspect here is that you have a "bad" package breaking the google namespace. (The fact that you have the very old gcloud co-tenant with google-cloud isn't a good sign.)

  21. ensonic commented on Feb 21, 2017

    @ensonic
    ensonic
    on Feb 21, 2017
    More actions

    @dhermes

    python -c "import google; print(google.__path__)"
    ['/usr/local/lib/python2.7/dist-packages/google']
    

    which ones should I get rid of - the 'grpc-google-' or 'gapic-google-'

  22. dhermes commented on Feb 21, 2017

    @dhermes
    dhermes
    on Feb 21, 2017
    Contributor
    More actions

    Neither need be gotten rid of AFAIK. From there you'd want to poke around in /usr/local/lib/python2.7/dist-packages/google/__init__.py and see if it is a namespace package or otherwise (you also need to look around for (maybe bad?) .nspkg files in your site-packages

  23. atulep
    added 2 commits that reference this issue on Apr 6, 2023

    Speech API: enhanced model and recognition metadata [(#1436)](GoogleC…

    9358952

    Speech API: enhanced model and recognition metadata [(#1436)](GoogleC…

    1684b04
  24. atulep
    added a commit that references this issue on Apr 18, 2023

    Speech API: enhanced model and recognition metadata [(#1436)](GoogleC…

    f53464c
  25. parthea
    added a commit that references this issue on Oct 22, 2023

    Speech API: enhanced model and recognition metadata [(#1436)](GoogleC…

    e3dc3d7
  26. parthea
    added 2 commits that reference this issue on Nov 24, 2025

    fix(rest): Use strict encoding to lowercase query string bools (#1436)

    b944206

    fix: fix user cred universe domain issue (#1436)

    e83a0fa
  27. parthea
    added a commit that references this issue on Mar 6, 2026

    docs: created samples for load table and create table from schema file (

    0cf66d4
  28. parthea
    added a commit that references this issue on Apr 1, 2026

    feat: Support dry_run in `to_pandas()` (#1436)

    3719a31
  29. parthea
    added a commit that references this issue on Sep 8, 2026

    docs: migrate code from googleapis/python-bigquery (#18303)

    23f9a74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @theacodes
    theacodes

Labels

packaging

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.