【问题标题】:Installing Google App Engine Python SDK with MacPorts使用 MacPorts 安装 Google App Engine Python SDK
【发布时间】:2015-01-15 03:46:11
【问题描述】:

我正在尝试使用 MacPorts 安装 Google App Engine Python SDK。

我安装了 Python 2.7(使用 MacPorts),并且刚刚安装了 GAE SDK:

sudo port install py-googleappengine

似乎安装正确。然而,当我运行 Python 时,

Python 2.7.9 (default, Dec 13 2014, 15:13:49) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.appengine.api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named appengine.api

我已验证所使用的 Python 是来自 MacPorts 的 Python,而不是 Apple 的 Python:

$ which python
/opt/local/bin/python

我发现文件 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/googleappengine.pth 包含

/opt/local/share/google_appengine

也存在。

我不确定为什么无法导入库。有什么想法吗?

更新:问题是与“google/protobuf/”存在冲突,它使用相同的命名空间并遮盖了新的 google 命名空间(sigh,我想命名空间是为了避免这种情况......);当我删除包含 protobuf 的“google”文件夹并尝试导入 google 时,它​​什么都不包含。我不确定我在清理过程中遗漏了什么文件。

【问题讨论】:

    标签: google-app-engine python-2.7 macports


    【解决方案1】:

    这是安装 GAE 后的预期行为。您不会以这种方式使用 GAE。

    相反,您需要:

    1. enabling the dev server 之后在本地主机上运行您的 Python 代码(例如,通过您的网络浏览器),或者
    2. 使用 nose-gae 测试您的 Python 代码。

    【讨论】:

    • 感谢您的回答!但实际上我正在尝试编写一个使用远程 api 的独立脚本,因此不是真正的 GoogleApp。
    猜你喜欢
    • 1970-01-01
    • 2016-12-21
    • 2018-02-10
    • 2020-12-13
    • 1970-01-01
    • 2018-04-29
    • 2016-05-23
    • 1970-01-01
    • 2020-05-12
    相关资源
    最近更新 更多