简体   繁体   English

无法访问Google AppEngine外部库

[英]Can't access Google AppEngine external libraries

Please help... I am running some python code from cygwin and I can't import the GoogleAppEngine (GAE) External Data API. 请帮忙......我正在运行一些来自cygwin的python代码,我无法导入GoogleAppEngine(GAE)外部数据API。 I think this may be an environment variable problem. 我认为这可能是一个环境变量问题。 I am able to run GAE and the 'remote_data_api_shell.py' from the command line, but I cannot run a python module that references GAE. 我可以从命令行运行GAE和'remote_data_api_shell.py',但我无法运行引用GAE的python模块。

I'm in trial-and-error mode trying every combination of environment variable strings I can think of. 我正在尝试试错模式,尝试我能想到的环境变量字符串的每个组合。 Nothing works and my frustration is mounting. 什么都行不通,我的挫折感越来越大。

  1. GAE(1.5) is located in (windows path): C:\\Program Files (x86)\\Google\\google_appengine GAE(1.5)位于(windows路径):C:\\ Program Files(x86)\\ Google \\ google_appengine

  2. Here is my Python Error: 这是我的Python错误:

Traceback (most recent call last): File "/cygdrive/c/data/my-program/MyProgram.py", line 48, in '<'module'>' 回溯(最近一次调用最后一次):在'<'module'>'中输入文件“/cygdrive/c/data/my-program/MyProgram.py”,第48行

from Model import MyStoredObject File "/cygdrive/c/data/my-program/Model.py", line 6, in '<'module'>' from google.appengine.ext import db ImportError: No module named google.appengine.ext 来自模型导入MyStoredObject文件“/cygdrive/c/data/my-program/Model.py”,第6行,在'<'module'>'中来自google.appengine.ext import db ImportError:没有名为google.appengine的模块。 EXT

  1. I setup my environment variables in my cygwin bashrc file. 我在我的cygwin bashrc文件中设置我的环境变量。 My bashrc file contains 我的bashrc文件包含

    GAE_HOME="/cygdrive/c/Program\\ Files\\ (x86)/Google/google_appengine" GAE_HOME =“/ cygdrive / c / Program \\ Files \\(x86)/ Google / google_appengine”

    I tried many combinations of strings and characters here. 我在这里尝试了许多字符串和字符的组合。

    PATH="$PATH:$GAE_HOME PATH =“$ PATH:$ GAE_HOME

    PYTHONPATH="$PYTHONPATH:$GAE_HOME:$GAE_HOME/lib/yaml/lib: PYTHONPATH =“$ PYTHONPATH:$ GAE_HOME:$ GAE_HOME / lib目录/ YAML / lib目录下:

    Also tried $GAE_HOME/google/appengine/ext and many more... 还尝试了$GAE_HOME/google/appengine/ext等等......

    export PYTHONPATH 出口PYTHONPATH

    export PATH 出口PATH

    export GAE_HOME 导出GAE_HOME

How can I make this work? 我怎样才能做到这一点? Anything obvious to a GAE expert that I'm doing wrong here? 对于GAE专家来说,我在这里做错了什么?

I have this at the top of scripts I run that need to interact with the appengine SDK 我在运行的脚本的顶部有这个需要与appengine SDK交互

import sys
import os

# locate app-engine SDK
AE_PATH = "/path/to/sdk/google_appengine/"

# path to app code
APP_PATH = os.path.abspath(".")

# load the AE paths (as stolen from dev_appserver.py)
EXTRA_PATHS = [
    APP_PATH,
    AE_PATH,
    os.path.join(AE_PATH, 'lib', 'antlr3'),
    os.path.join(AE_PATH, 'lib', 'django'),
    os.path.join(AE_PATH, 'lib', 'ipaddr'),
    os.path.join(AE_PATH, 'lib', 'webob'),
    os.path.join(AE_PATH, 'lib', 'yaml', 'lib'),
    os.path.join(AE_PATH, 'lib', 'fancy_urllib'), # issue[1]
]
sys.path = EXTRA_PATHS + sys.path

[1] fancy_urllib issue [1] fancy_urllib问题

Hopefully that points you in the right direction 希望这能指出你正确的方向

This should fix the paths: 这应该修复路径:

sdk_path = "/path/to/sdk/google_appengine/"
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM