每次修改源后都会发生错误

时间:2012-08-23 18:28:23

标签: google-app-engine internationalization webapp2 babel

我正在尝试在jinja2的谷歌应用引擎中使用i18n。

我在这里找到了一个教程http://webapp-improved.appspot.com/tutorials/i18n.html

除了一件事,一切都很好。

每次修改导入webapp2_extras.i18n的.py文件后都出错了。

这是错误消息。

  ERROR    2012-08-23 18:31:51,505 wsgi.py:191] 
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 189, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 227, in _LoadHandler
    handler = __import__(path[0])
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1859, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1723, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1666, in LoadModuleRestricted
    description)
  File "C:\Users\Jinmo\dev\src\simpletest\simpletest.py", line 5, in <module>
    from webapp2_extras import i18n
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1859, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1723, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1666, in LoadModuleRestricted
    description)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2\webapp2_extras\i18n.py", line 16, in <module>
    import babel
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1859, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1723, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1666, in LoadModuleRestricted
    description)
  File "C:\Users\Jinmo\dev\src\simpletest\babel\__init__.py", line 33, in <module>
    from pkg_resources import get_distribution, ResolutionError
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1859, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1723, in FindAndLoadModule
    description)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 1648, in LoadModuleRestricted
    return source_file.load_module(submodule_fullname)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist\py_zipimport.py", line 246, in load_module
    submodname, is_package, fullpath, source = self._get_source(fullmodname)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist\py_zipimport.py", line 207, in _get_source
    source = self.zipfile.read(relpath.replace(os.sep, '/'))
  File "C:\Program Files\Python27\lib\zipfile.py", line 869, in read
    return self.open(name, "r", pwd).read()
  File "C:\Program Files\Python27\lib\zipfile.py", line 884, in open
    zef_file = open(self.filename, 'rb')
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py", line 592, in __init__
    raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: 'C:\\Program Files\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg'

这是'simepletest.py'。

import os
import logging
import webapp2
import jinja2
from webapp2_extras import i18n

jinja_environment = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.out.write('Hello, world!')


app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)

def main():
    logging.getLogger().setLevel(logging.DEBUG)
    run_wsgi_app(app)

if __name__ == '__main__':
    main()

这是'app.yaml'。

application: simpletest
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: simpletest.app

libraries:
- name: jinja2
  version: latest

我的app目录中有babel和pytz库目录。

启动开发服务器后第一次,没关系。我可以很好地看到我的网页。

但是,如果我只是在simpletest.py中添加[enter],则会发生错误。

1 个答案:

答案 0 :(得分:0)

这不是一个真正的答案,只是另一种解决方法..尝试禁用:

C:\\Program Files\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg

将其重命名为:

setuptools-0.6c11-py2.7.egg_DISABLED

您需要重新启用它来安装本地Python软件包,但是,如果我是对的,它将解决您的问题..