1

Goal: Use GAE with Python and Google Cloud Storage to store and serve an image more efficiently to ultimately use the image API.

Problem: Cannot find correct modules (httplib2 and six) despite successful install.


Run time example

Python Code Sample A:

from google.cloud import storage
from google.appengine.api import app_identity
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
import webapp2

Returns Sample A:

ImportError: No module named google_auth_httplib2

Note: Also had a similar error for six. "no module named six"


Installed Details

python installed at:

C:\Python27

six installed at:

C:\python27\lib\site-packages\six-1.10.0-py2.7.egg

httplib2 installed at:

C:\Python27\Lib\site-packages\httplib2-0.9.2-py2.7.egg-info

Running “C:>pip install httplib2” in the command line returns:

“Requirement already satisfied: httplib2 in c:\python27\lib\site-packages”

Running “C:>pip install six” in the command line returns:

Requirement already satisfied: six in c:\python27\lib\site-packages\six-1.10.0-py2.7.egg

GAE Cloud Storage Client installed at:

C:\Python27\Lib\site-packages\GoogleAppEngineCloudStorageClient-1.9.22.1-py2.7.egg-info

GAE SDK Server Hosting using "dev_appserver.py ." at:

C:\Users\sebastian\Documents\Web Projects\Cookbook

This location also contains the app.yaml file.

Copied modules to app.yaml location

Copied the httplib2 and six-1.10.0-py2.7.egg folders to my app.yaml directory.


Appendix 1:

App.yaml

runtime: python27
api_version: 1
threadsafe: true

handlers:

    - url: /
      script: homegcs.app

    - url: /static
      static_dir: static

    - url: /.*
      script: home.app

    - url: /index\.html
      script: home.app

    - url: /stylesheets
      static_dir: stylesheets

    - url: /(.*\.(gif|png|jpg))$
      static_files: static/\1
      upload: static/.*\.(gif|png|jpg)$

    - url: /admin/.*
      script: admin.app
      login: admin

    - url: /.*
      script: not_found.app

Folder structure containing App.yaml

Seb Taylor
  • 19
  • 1
  • 5

2 Answers2

1

Your packages either need to be uploaded with the project, or added in app.yaml, if they are available in App Engine. six is an available library, so, in app.yaml, add:

libraries:
- name: six
  version: "1.9.0"

If you put the httplib2 package at the same level as app.yaml, it should upload with the project, and be available in production.

Another user added google_auth_httplib2 as a package as well, and uploaded it with the project. Though I think that should be available directly:

Module google_auth_httplib2 not found after pip installing google-cloud How can I fix it?

** You also have an issue in your url handlers in app.yaml. This is a wildcard for all urls:

- url: /.*
    script: home.app

So, every handler below that will not ever be hit.

Community
  • 1
  • 1
GAEfan
  • 11,244
  • 2
  • 17
  • 33
  • Thanks, that certainly solves 2 of 4 of the apparent issues. (six and yaml handlers). I've added a picture of the folder structure, as I already have both httplib2 and google_auth_httplib2 in my app.yaml directory but it still throws the same error with regards google_auth_httplib2 not found. – Seb Taylor Feb 08 '17 at 04:26
  • `httplib2` and `google_auth_httplib2` are 2 different packages. Your error is that your code is looking for `google_auth_httplib2`, while you have `httplib2`. Switch your code, or use the correct package (see the link in my answer as to how another user did that) – GAEfan Feb 08 '17 at 05:56
0

You need to install google-cloud in your project, like this:

pip install google-cloud -t [my_project]/lib/google-cloud

Make sure you create that google-cloud folder first, inside your lib folder. Once you do that, change or create appengine_config.py (in /my_project) and include this:

from google.appengine.ext import vendor

vendor.add('lib/google-cloud')

Everything shoul work now.

Yamil Abugattas
  • 408
  • 3
  • 20
  • thanks, tht certainly seems to have fixed some of it. the error now reads "from google.cloud import storage Import Error: No module named cloud" @yamilabugattas – Seb Taylor Feb 22 '17 at 04:43
  • Are you sure the folder is in the directory specified in appengine_config.py? Make sure you pip install in that folder. Also try adding from __future__ import absolute_import at the beginning of the file. – Yamil Abugattas Feb 22 '17 at 11:46