导入GAE内存缓存时,pydev会出错

时间:2014-05-09 14:14:37

标签: python eclipse google-app-engine pydev

所以,在我寻找good Python IDE that support webapp2的过程中,我建议将Eclipse与pydev的插件一起使用。

在干净的Eclipse版本中成功安装后,我创建了一个GAE项目。除memcache外,每件事似乎都运行良好。由于某种原因,IDE不编译以下python代码,即使代码是完全合法的:

from google.appengine.api import memcache

class FlushMemCache(BlogHandler):
    def get(self):
        memcache.flush_all()
        self.redirect(BLOG_FRONT_URL)

我得到的只是错误Undefined variable from import: flush_all。对于memcache中的所有方法都会发生这种情况。奇怪的是,如果我在不使用Eclipse的情况下在GAE上运行它,网页会加载并且一切正常。

此外,当我按F2进行聚焦并使用Eclipse的控制台测试一些代码时,我也会遇到以下错误:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
/usr/bin/python 2.7.4 (default, Sep 26 2013, 03:20:26) 
[GCC 4.7.3]
PyDev console: using default backend (IPython not available).
from google.appengine.api import memcache
memcache.set('hello world', 'ola')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/pedro/google_appengine/google/appengine/api/memcache/__init__.py", line 763, in set
    namespace=namespace)
  File "/home/pedro/google_appengine/google/appengine/api/memcache/__init__.py", line 868, in _set_with_policy
    time, '', namespace)
  File "/home/pedro/google_appengine/google/appengine/api/memcache/__init__.py", line 970, in _set_multi_async_with_policy
    (server_keys, user_key))
  File "/home/pedro/google_appengine/google/appengine/api/memcache/__init__.py", line 380, in _make_async_call
    rpc = create_rpc()
  File "/home/pedro/google_appengine/google/appengine/api/memcache/__init__.py", line 294, in create_rpc
    return apiproxy_stub_map.UserRPC('memcache', deadline, callback)
  File "/home/pedro/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 413, in __init__
    self.__rpc = CreateRPC(service, stubmap)
  File "/home/pedro/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 67, in CreateRPC
    assert stub, 'No api proxy found for service "%s"' % service
AssertionError: No api proxy found for service "memcache"

我错过了一些配置细节吗?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

您确定Google App Engine DEV服务器已启动吗? 我想这是你的问题。您的代码有效,但需要启动DEV服务器以响应您的呼叫并运行内存缓存机制。

如果您不想启动Google App Engine并只想在项目中导入memcache库,则可以see this solution

相关问题