IOError: [Errno 13] Google AppEngine 1.6.1 文件不可访问

11 投票
6 回答
8346 浏览
提问于 2025-04-17 09:54

也许这是个bug,但我还是想在这里发帖。

我在本地的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'

我可能错了,但这似乎是我之前没有遇到过的问题。自从2011年12月13日Google App Engine发布以来,我在想这是否可能与这个版本有关。

我使用的是pythonbrew、virtualenv,操作系统是Mac Os X 10.6.8。

谢谢你的帮助!

6 个回答

6

简单来说,就是把文件 setuptools-0.6c11-py2.7.egg 从你的站点包中删除掉。

找到你站点包的位置

首先,打开 Python 命令行界面:

python

然后,列出站点包:

>>> import site; site.getsitepackages()
14

我有另一个解决他问题的方法,这是我自己遇到过的。如果你的模板目录像这样:

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

而你的 app.yaml 文件像这样:

- url: /templates
  static_dir: templates

如果你使用这个名字,你就无法用 jinja2 渲染模板:

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

我觉得这是因为 static_dir 选项以某种方式阻止了 jinja2 访问这个目录,至少我这么认为,也许这对某些人有帮助!

4

我现在不再用固定的路径来引用我的变量,而是使用:

PROJECT_DIR = os.path.dirname(__file__)

这样做是有效的。如果问题再次出现,我会告诉你(我看到一些文章说这个问题是偶尔会出现的)。

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

撰写回答