GAE:使用google-auth时的ImportError

时间:2017-09-28 03:43:37

标签: python django google-app-engine importerror google-authentication

我正在使用public class Falcon extends FlyingAnimal { public void fly(){ System.out.println("I'm a fast flier"); } public class Eagle extends FlyingAnimal { public void fly(){ System.out.println("I'm built for soaring"); } public class Cat extends Animal { // I'm a cat; I can't fly } 在我的GAE项目中允许firebase身份验证。

当我使用public void flyIt(FlyingAnimal fa){ fa.fly(); } public void test(){ Falcon falcon = new Falcon(); Animal eagle = new Eagle(); Animal cat = new Cat(); flyIt(falcon); // OK: `Falcon` is a `Falcon`, which is also // a `FlyingAnimal` flyIt(cat); // COMPILE ERROR: `cat` is an `Animal`, // which is not a subclass of `FlyingAnimal` flyIt(eagle); // COMPILE ERROR: `eagle` is an `Animal`, which is // not a `FlyingAnimal` flyIt((Eagle)eagle); // OK: because we know that `eagle` actually references // an `Eagle`, we know the type-cast `(Eagle)eagle` // will succeed at run-time; `Eagle` is a `FlyingAnimal` // and thus is acceptable as an argument to `flyIt` flytIt((FlyingAnimal)eagle); // OK: because we know that `eagle` actually references // an `Eagle`, which in turn is a `FlyingAnimal`, we // know the type-cast `(FlyingAnimal)eagle` will // succeed at run-time flyIt((FlyingAnimal)cat); // RUN-TIME ERROR: `cat` references a `Cat`, which is // an `Animal` but not a `FlyingAnimal`, and so will // not successfully convert to a `FlyingAnimal` at // run-time. 在本地运行代码或将其部署到Google应用引擎时,一切正常。

但是当我尝试使用Django的google-auth脚本来创建/运行迁移时,我得到了这个dev_appserver.py例外。

ImportError

manage.py模块安装在ImportError: Could not import 'firebase.authentication.FirebaseAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: No module named auth.transport.requests. 目录下,具有以下结构:

google-auth

这些导入导致lib

- lib
        - google
            - auth
            - oauth2

我的猜测是,可能存在命名冲突,因为其他导入工作正常。

请帮忙!

1 个答案:

答案 0 :(得分:0)

如果您想使用this list中未包含的第三方库,那么您必须手动添加它们,因为您已经通过添加lib文件夹并包括所有包文件夹来执行此操作,请按照以下步骤操作。

创建your_app_directory / appengine_config.py文件。

在该文件中添加以下这些行

from google.appengine.ext import vendor
vendor.add('lib')

这应解决导入错误问题。