GAE下python之importmodules{No module named %s}解决方法

笔者菜菜,想看看github上tornado写的demo ---blog,于是在github上粘贴复制,粘贴复制,

用GAE打开的时候发现跑不起来,看看log

File "E:\Python27\lib\ctypes\__init__.py", line 10, in <module>

from _ctypes import Union, Structure, Array

File "E:\GAE\google\appengine\tools\devappserver2\python\sandbox.py", line 900, in load_module

raise ImportError('No module named %s' % fullname)

于是搜google找baidu,终于找到解决方法了:http://stackoverflow.com/questions/6431495/how-do-i-know-if-my-code-is-running-deployed-on-gae-or-running-local

其实是因为GAE对PYTHON2.7某些modules是不支持的,而是完全支持2.5的

我们进入刚刚那个sandbox.py,查找 ImportError('No module named %s' % fullname)这句话找到:

  def find_module(self, fullname, path=None):
    if (fullname in _WHITE_LIST_C_MODULES or
        any(regex.match(fullname) for regex in self._enabled_regexes)):
      return None
    if self._module_type(fullname, path) in [imp.C_EXTENSION, imp.C_BUILTIN]:
      return self
    return None

  def load_module(self, fullname):
    raise ImportError('No module named %s' % fullname)
_WHITE_LIST_C_MODULES就是白名单啦,把错误的那个module名加上,finished~,run~~,successful~~~~~hoho~~~

 

posted @ 2014-11-28 00:03  KiddingJohn  阅读(926)  评论(0编辑  收藏  举报