简体   繁体   English

Python上的Google App Engine“ ImportError:没有名为google.appengine.ext的模块”

[英]Google App Engine on Python “ImportError: No module named google.appengine.ext”

I am trying to set up a python source file for a Google Cloud. 我正在尝试为Google Cloud设置python源文件。 I have installed a GSUtil on my MAC OS 10.6 and set up the path for files as instructed on the page adding this command (export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil) to .bash_profile under the home directory. 我已经在我的MAC OS 10.6上安装了GSUtil,并按照添加此命令的页面上的说明设置了文件路径(export PYTHONPATH = $ {PYTHONPATH}:$ HOME / gsutil / boto:$ HOME / gsutil)到.bash_profile下主目录。

Then, I ran the following code: 然后,我运行了以下代码:

#!/usr/bin/python

import StringIO
import os
import shutil
import tempfile
import time
from oauth2_plugin import oauth2_plugin

import boto

# URI scheme for Google Cloud Storage.
GOOGLE_STORAGE = 'gs'
# URI scheme for accessing local files.
LOCAL_FILE = 'file'

And, the compiler gave me an error saying 而且,编译器给我一个错误提示

>>> [evaluate gs.py]
Traceback (most recent call last):
  File "/Volumes/WingIDE-101-4.0.0/WingIDE.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 8, in <module>
  File "/Users/lsangin/oauth2_plugin.py", line 18, in <module>
  File "/Users/lsangin/google_appengine/cloudauth/oauth2client/appengine.py", line 24, in <module>
    from google.appengine.ext import db
ImportError: No module named google.appengine.ext
>>> from google.appengine.ext

Can someone help me with the issue? 有人可以帮我解决这个问题吗? (Sorry, I am a newbie!) Thank you in advance. (对不起,我是新手!)预先谢谢您。

When you run or deploy your code as a Google App Engine application, the AE tools make sure you have access to the AE specific modules (eg google.appengine.ext) but it sounds like you're trying to run this script as a stand alone program, outside of app engine. 当您将代码作为Google App Engine应用程序运行或部署时,AE工具会确保您可以访问AE特定模块(例如google.appengine.ext),但这听起来像是您试图将这个脚本作为标准运行应用程序引擎之外的单独程序。 If so, you may not need the appengine module (hard to say for sure without seeing more of your code). 如果是这样,您可能不需要appengine模块(很难确定,而看不到更多代码)。 If I'm correct and this is a little test code to run outside AE, try commenting out the import and references to the missing module. 如果我是正确的,并且这是在AE外部运行的一些测试代码,请尝试注释掉导入和对缺少模块的引用。 Once you get that working, uncomment that code if/when you're ready to try your program under app engine (either the local dev environment or hosted service). 一旦可以正常工作,如果/当您准备在App Engine(本地开发环境或托管服务)下尝试使用程序时,请取消注释该代码。

Sounds like you are importing the wrong oauth2_plugin because the one in gsutil/oauth2_plugin does not depend on app engine. 听起来您正在导入错误的oauth2_plugin,因为gsutil / oauth2_plugin中的一个不依赖于应用引擎。

I had the same problem because I previously tested with gsutil/cloudauth/oauth2_plugin.py and it was still in PYTHONPATH. 我遇到了同样的问题,因为我之前使用gsutil / cloudauth / oauth2_plugin.py进行了测试,但它仍位于PYTHONPATH中。

Try refreshing the PYTHONPATH with: 尝试使用以下方法刷新PYTHONPATH:

PYTHONPATH=""
source ~/.bashrc

我遇到了同样的问题-我通过在我的PYTHONPATH中添加目录来解决了这个问题: https : //stackoverflow.com/a/19019234/1741654

Did you move (or copy) oauth2_plugin.py into a different place? 您是否将oauth2_plugin.py移动(或复制)到另一个位置? What you have in that stack trace shows cloudauth/oauth2_plugin.py (which is the plugin that works with app engine), not oauth2_plugin/oauth2_plugin.py (which is likely the one you want). 您在该堆栈跟踪中拥有的内容显示cloudauth/oauth2_plugin.py (与应用引擎一起使用的插件),而不是oauth2_plugin/oauth2_plugin.py (可能是您想要的那个)。

What's your full PYTHONPATH? 什么是完整的PYTHONPATH?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Engine:ImportError:没有名为appengine.ext的模块 - Google App Engine: ImportError: No module named appengine.ext ImportError:没有名为google.appengine.ext的模块(Cloud Endpoints Frameworks v2) - ImportError: No module named google.appengine.ext (Cloud Endpoints Frameworks v2) 没有名为 appengine.ext google app engine 的模块 - No module named appengine.ext google app engine Google App Engine(Python 2.7)Win 10 ImportError:没有名为appengine.api的模块 - Google App Engine (Python 2.7) Win 10 ImportError: No module named appengine.api Google App Engine启动器(Python)-ImportError:没有名为webapp2的模块 - Google App Engine Launcher (Python) - ImportError: No module named webapp2 Python ImportError:Google app引擎项目中没有名为main的模块 - Python ImportError: No module named main in Google app engine project Google App Engine-ImportError:没有名为edf的模块 - Google App Engine - ImportError: No module named edf 谷歌应用引擎中的“导入错误:没有名为装饰器的模块” - 'ImportError: No module named decorator' in google app engine Google App Engine ImportError:未命名模块 - Google App Engine ImportError: No module named ImportError:谷歌应用引擎中没有名为****的模块错误 - ImportError: No module named **** Error in google app engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM