【问题标题】:IOError: [Errno 13] file not accessible with Google AppEngine 1.6.1IOError:Google AppEngine 1.6.1 无法访问 [Errno 13] 文件
【发布时间】:2016-07-10 14:22:59
【问题描述】:

也许这是一个错误,但我还是在这里发帖。

我在本地 AppEngine 测试服务器上遇到以下问题:

WARNING  2012-01-10 06:08:40,336 rdbms_mysqldb.py:90] The rdbms API is not available because the MySQLdb library could not be loaded.
INFO     2012-01-10 06:08:40,470 appengine_rpc.py:159] Server: appengine.google.com
INFO     2012-01-10 06:08:40,474 appcfg.py:561] Checking for updates to the SDK.
INFO     2012-01-10 06:08:40,990 appcfg.py:574] Update check failed: HTTP Error 404: Not Found
WARNING  2012-01-10 06:08:47,643 dev_appserver.py:3344] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO     2012-01-10 06:08:47,654 dev_appserver_multiprocess.py:638] Running application dev~project_name on port 8080: http://localhost:8080
INFO     2012-01-10 06:08:47,654 dev_appserver_multiprocess.py:640] Admin console is available at: http://localhost:8080/_ah/admin
INFO     2012-01-10 06:09:14,989 dev_appserver_index.py:338] Created 2 and deleted 0 index(es); total 2
WARNING  2012-01-10 06:09:15,480 py_zipimport.py:139] Can't open zipfile /Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg: IOError: [Errno 13] file not accessible: '/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg'
ERROR    2012-01-10 06:09:16,927 bottle.py:746] Traceback (most recent call last):
  File "/Users/ca/Dropbox/Perso/projects/project_name/Source/project_name/lib/bottle.py", line 735, in _handle
    return route.call(**args)
  File "/Users/ca/Dropbox/Perso/projects/project_name/Source/project_name/lib/bottle.py", line 1451, in wrapper
    rv = callback(*a, **ka)
  File "/Users/ca/Dropbox/Perso/projects/project_name/Source/project_name/tools.py", line 41, in render_to_response
    template = jinja_env.get_template(template_name)
  File "/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/jinja2/environment.py", line 719, in get_template
  File "/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/jinja2/environment.py", line 693, in _load_template
  File "/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/jinja2/loaders.py", line 115, in load
  File "/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/jinja2/loaders.py", line 165, in get_source
  File "/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/jinja2/utils.py", line 224, in open_if_exists
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 578, in __init__
    raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/Users/ca/Dropbox/Perso/Projects/project_name/Source/project_name/templates/tools_list.html'

INFO     2012-01-10 06:09:16,962 dev_appserver.py:2832] "GET / HTTP/1.1" 500 -
INFO     2012-01-10 06:09:16,974 dev_appserver_index.py:255] Updating /Users/ca/Dropbox/Perso/projects/project_name/Source/project_name/index.yaml
WARNING  2012-01-10 06:11:36,153 py_zipimport.py:139] Can't open zipfile /Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg: IOError: [Errno 13] file not accessible: '/Users/ca/.pythonbrew/venvs/Python-2.7.2/project_name/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg'

我可能错了,但似乎这是我以前没有遇到的问题。自 Google App Engine 于 2011 年 12 月 13 日发布以来;我想知道它是否可以来自这个版本。

我正在使用 pythonbrew、virtualenv、Mac Os X 10.6.8

感谢您的帮助!

【问题讨论】:

    标签: python google-app-engine


    【解决方案1】:

    我对他的问题有另一个答案,我自己也经历过。例如,如果您有这样的模板目录:

    templates
    |-- css
    |-- img
    |-- js
    |-- html
    

    你的 app.yaml 文件是这样的:

    - url: /templates
      static_dir: templates
    

    如果您使用此名称,您将无法使用 jinja2 呈现模板:

    JINJA_ENVIRONMENT.get_template('html/index.html')
    

    我认为这是因为 static_dir 选项以某种方式阻止了 jinja2 的此目录,至少我认为是这样,也许它可以帮助某人!

    【讨论】:

    • 是的,我遇到了这个问题。 GAE 目前不允许从应用程序代码中访问static_dir 中的文件。
    • 这只是默认行为。但可以使用application_readable: true 选项覆盖它,请参阅stackoverflow.com/a/16541092/4495081
    【解决方案2】:

    只需从您的站点包中删除文件 setuptools-0.6c11-py2.7.egg

    查找站点包的位置

    启动 python CLI:

    python
    

    列出站点包:

    >>> import site; site.getsitepackages()
    

    【讨论】:

      【解决方案3】:

      我现在使用的是:而不是使用硬编码的路径变量来引用我的变量:

      PROJECT_DIR = os.path.dirname(__file__)
      

      而且它正在工作。如果问题再次出现,我会通知您(我看到一些文章将其描述为随机复发)。

      我还在http://code.google.com/p/googleappengine/issues/detail?id=4339的评论29中应用了补丁

      【讨论】:

      • 我在哪里添加这个 PROJECT_DIR ?
      • 我有一个settings.py,我将它导入到我需要访问这些全局变量的所有文件中。
      【解决方案4】:

      可能会迟到,但可能会帮助其他人。
      所以,当你添加

      jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates'))
      

      不要添加
      - url: /templates static_dir: templates
      到您的 app.yaml 文件

      【讨论】:

      【解决方案5】:

      我对类似的问题感到困惑 - 从站点包导入鸡蛋文件/包时出现 IOError。我正在使用 Ubuntu 13.10、GAE 1.8.8、virtualenv 和 python 2.7。

      最后,我发现我无法导入使用 easy_install 安装的任何东西(默认情况下,它将 egg 文件放入 site_packages)。

      一旦我卸载了所有这些鸡蛋,并使用 pip install 命令重新安装,一切都开始正常工作了。

      希望这会为其他人节省一些时间,因为我永远不会收回浪费的时间。

      【讨论】:

        【解决方案6】:

        在某些情况下,当文件名与 app.yaml 中的 skip_files 模式匹配时,dev_appserver.py 为 open 调用返回失败会导致此错误。即使在本地运行 dev_appserver.py 也要检查 app.yaml。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-08-10
          • 1970-01-01
          • 2013-03-18
          • 1970-01-01
          • 2018-03-14
          • 2021-05-01
          相关资源
          最近更新 更多