Google Cloud and Appengine Python Package conflict

941 views Asked by At

I'm going through google's appengine tutorials and made the simple example of posting a form ans retrieving the information. Through the tutorial steps I had to install Google Cloud SDK with the appengine libs.

It works fine.

One step forward I pip installed "google-cloud" package, to retrieve a file from Google Storage.

After installed both google cloud packages,when trying a simple import from my main.py file as:

from google.cloud import storage

I get the error:

ImportError: No module named google.cloud.storage

Printing google.__path__ I can see the correct path to both packages:

[
'/home/xpto/.virtualenvs/dev01/local/lib/python2.7/site-packages/google',
'/home/xpto/.virtualenvs/dev01/lib/python2.7/site-packages/google', 
'/home/xpto/Software/google-cloud-sdk/platform/google_appengine/google', 
'/home/xpto/projects/testProject01/lib/google'
]

What am I missing here?

Running python from the terminal in the same virtualenv I can import google.clou packages without problem. The error message appears only when I run it using dev_appserver.py

2

There are 2 answers

0
Maviles On BEST ANSWER

The problem was that I installed Google Cloud SDK using the Linux tar.gz package instead of the Debian/Ubuntu installation procedure.

Somehow the tar.gz package messed up my python path. Creating a new environment solved.

6
Bill Prin On

Dan Cornilescu linked to this question which looks it might work.

If that doesn't work, you can usually hack import paths to fix it. I usually don't add the app engine SDK to my virtualenv at all and then just add it manually:

import google

google.__path__.append('/path/to/appengine_sdk//google_appengine/google')
sys.path.insert(0, gae_dir) # might not be necessary

import google.appengine # now it's on your import path`

Leave a comment if none of these approaches work.