2

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

Maviles
  • 3,209
  • 2
  • 25
  • 39
  • It seems to be a duplicate of [Python on Google Cloud](http://stackoverflow.com/questions/25100031/install-python-google-cloud-storage-client-on-ubuntu-14-04). – Prabir Ghosh Jan 03 '17 at 02:17
  • potentially relevant: http://stackoverflow.com/questions/41399303/using-two-python-libraries-with-conflicting-names – Dan Cornilescu Jan 03 '17 at 03:45
  • Dan Cornilescu, I think it is something like this, but I already have the appengine_config.py identical to the proposed solution. Have any other ideas? I added more info to the question. – Maviles Jan 04 '17 at 00:59
  • Not really, I managed to stick with the GAE SDK so far, didn't switch to the cloud SDK yet. See http://stackoverflow.com/questions/33769879/what-is-the-relationship-between-googles-app-engine-sdk-and-cloud-sdk. But that's not what's being recommended these days, tho... Monitoring related threads, tho - I know I have to switch eventually. – Dan Cornilescu Jan 04 '17 at 05:47

2 Answers2

3

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.

Community
  • 1
  • 1
Bill Prin
  • 2,498
  • 1
  • 20
  • 27
  • Hi Bill, the path to both packages are already listed in the google.__path__ . I added more info to the question. Any other ideas? – Maviles Jan 04 '17 at 01:01
  • Yes mine is identical to the one proposed in Dan Cornilescu link. – Maviles Jan 04 '17 at 22:33
  • @Maviles, sorry you have me a bit stumped, maybe if you can repro it on a simple Github repo I can take a look? – Bill Prin Jan 09 '17 at 20:49
  • Hi Bill, I put it on github repo https://github.com/mhaa/gclouderror much appreciate the help. thanks – Maviles Jan 11 '17 at 02:42
  • Your code sample runs fine on dev_appserver.py for me with no import errors. On gcloud 139.0.1. Are you by chance messing with your PYTHONPATH environment variable before running dev_appserver.py? – Adam Jan 14 '17 at 20:35
  • Thanks @Adam, As it worked for you and I couldn't find out the error, the only way was to start a whole new enviroment. Now it is working. So it was probably a configuration error. – Maviles Jan 29 '17 at 20:45
0

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.

Maviles
  • 3,209
  • 2
  • 25
  • 39