Reputation: 19
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
Upvotes: 1
Views: 2955
Reputation: 418
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.
Upvotes: 0
Reputation: 11360
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.
Upvotes: 1