Skip to content

ImportError: cannot import name 'connection' in logs when deploying via App Engine #689

Closed

Description

@jeremykeen

In which file did you encounter the issue?

python-docs-samples/appengine/flexible/pubsub/main.py

Did you change the file? If so, how?

No

Describe the issue

Error when deploying to App Engine:
from google.cloud.pubsub.connection import Connection File "/env/lib/python3.4/site-packages/google/cloud/pubsub/connection.py", line 19, in <module> from google.cloud import connection as base_connection ImportError: cannot import name 'connection'

In the CLI I eventually get the below error and the app simply is repeatedly relaunching.

ERROR: (gcloud.app.deploy) Error Response: [13] Timed out when starting VMs. It's possible that the application code is unhealthy.

Activity

  1. theacodes commented on Nov 29, 2016

    @theacodes
    Contributor

    Hi @jkeenest does this work locally? Can you share the entire stacktrace/deploy output?

  2. jeremykeen commented on Nov 30, 2016

    @jeremykeen
    Author

    locally run..

    Traceback (most recent call last): File "main.py", line 22, in <module> from google.cloud import pubsub File "C:\Users\keenj\AppData\Local\Programs\Python\Python35-32\lib\site-packages\google\cloud\pubsub\__init__.py", line 27, in <module> from google.cloud.pubsub.client import Client File "C:\Users\keenj\AppData\Local\Programs\Python\Python35-32\lib\site-packages\google\cloud\pubsub\client.py", line 21, in <module> from google.cloud.pubsub.connection import Connection File "C:\Users\keenj\AppData\Local\Programs\Python\Python35-32\lib\site-packages\google\cloud\pubsub\connection.py", line 19, in <module> from google.cloud import connection as base_connection ImportError: cannot import name 'connection'

  3. theacodes commented on Nov 30, 2016

    @theacodes
    Contributor

    Hi Jeremy, it seems you might have an old/broken install of the google cloud libraries. Can you send over the output of pip freeze?

    You should use a virtualenv when working locally, this will ensure the sample has the correct version of the dependencies.

  4. jeremykeen commented on Dec 2, 2016

    @jeremykeen
    Author

    Tried again with a new clone and virtualenv locally. This worked. Now for deploying in App Engine... I was getting errors from Cloud Compute re: alpha not enabled. I will try to reproduce. Changed zones and now it works.

  5. theacodes commented on Dec 2, 2016

    @theacodes
    Contributor

    Great, I'm gonna close this issue but feel free to reach out if you need anything else.

  6. added a commit that references this issue on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions