没有名为google_auth_httplib2

时间:2017-02-07 06:18:46

标签: python-2.7 google-app-engine google-cloud-storage httplib2 six

目标:将GAE与Python和Google云存储结合使用,可以更有效地存储和提供图像,最终使用图像API。

问题:尽管安装成功,但找不到正确的模块(httplib2和6)。

运行时示例

Python代码示例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

返回样本A:

  

ImportError:没有名为google_auth_httplib2的模块

注意:六个也有类似的错误。 “没有名为六的模块”

已安装的详细信息

python安装在:

C:\Python27

六个安装在:

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

httplib2安装在:

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

在命令行中运行“C:> pip install httplib2”返回:

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

在命令行中运行“C:> pip install six”返回:

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

GAE云存储客户端安装在:

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

使用“dev_appserver.py”进行GAE SDK服务器托管。在

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

此位置还包含app.yaml文件。

将模块复制到app.yaml位置

httplib2six-1.10.0-py2.7.egg个文件夹复制到我的app.yaml目录。

附录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

2 个答案:

答案 0 :(得分:1)

您的软件包需要随项目一起上传,或者在app.yaml中添加(如果它们在App Engine中可用)。 six是一个可用的库,因此,在app.yaml中,添加:

libraries:
- name: six
  version: "1.9.0"

如果您将httplib2软件包放在与app.yaml相同的级别,则应将其与项目一起上传,并在生产中使用。

另一位用户也将google_auth_httplib2添加为一个包,并将其与项目一起上传。虽然我认为应该直接提供:

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

** app.yaml中的网址处理程序也存在问题。这是所有网址的通配符:

- url: /.*
    script: home.app

因此,下面的每个处理程序都不会被命中。

答案 1 :(得分:0)

您需要在项目中安装google-cloud,如下所示:

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

确保首先在lib文件夹中创建google-cloud文件夹。完成后,更改或创建appengine_config.py(在/ my_project中)并包括:

from google.appengine.ext import vendor

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

现在一切都在努力。