"无法将文件提取到egg cache" GAE中的错误

时间:2014-06-15 15:07:27

标签: python google-app-engine python-2.7 python-egg-cache

我安装了安装了setuptools的Windows 7和Python 2.7。

下载pitz模块(easy_install pitz)后,Google App Engine停止工作:

bad runtime process port ['']

Traceback (most recent call last):
  File "G:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 184, in <module>
    _run_file(__file__, globals())
  File "G:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 180, in _run_file
    execfile(script_path, globals_)
  File "G:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 28, in <module>
    from google.appengine.ext.remote_api import remote_api_stub
  File "G:\Program Files (x86)\Google\google_appengine\google\appengine\ext\remote_api\remote_api_stub.py", line 75, in <module>
    import yaml
  File "G:\Program Files (x86)\Google\google_appengine\lib\yaml-3.10\yaml\__init__.py", line 14, in <module>
    from cyaml import *
  File "G:\Program Files (x86)\Google\google_appengine\lib\yaml-3.10\yaml\cyaml.py", line 5, in <module>
    from _yaml import CParser, CEmitter
  File "C:\Python27\lib\site-packages\pyyaml-3.11-py2.7-win-amd64.egg\_yaml.py", line 7, in <module>
  File "C:\Python27\lib\site-packages\pyyaml-3.11-py2.7-win-amd64.egg\_yaml.py", line 4, in __bootstrap__
  File "C:\Python27\lib\site-packages\pkg_resources.py", line 950, in resource_filename
    self, resource_name
  File "C:\Python27\lib\site-packages\pkg_resources.py", line 1607, in get_resource_filename
    self._extract_resource(manager, self._eager_to_zip(name))
  File "C:\Python27\lib\site-packages\pkg_resources.py", line 1667, in _extract_resource
    manager.extraction_error()
  File "C:\Python27\lib\site-packages\pkg_resources.py", line 996, in extraction_error
    raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Error 5] : 'C:\\Users\\Kostr\\AppData\\Roaming\\Python-Eggs\\pyyaml-3.11-py2.7-win-amd64.egg-tmp\\_yaml.pyd'

The Python egg cache directory is currently set to:

  C:\Users\Kostr\AppData\Roaming\Python-Eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

如何解决这个问题?

2 个答案:

答案 0 :(得分:3)

来自:https://code.google.com/p/modwsgi/wiki/ApplicationIssues

要避免此特定问题,可以在WSGI应用程序脚本文件的开头设置PYTHON_EGG_CACHE缓存环境变量。环境变量应设置为Apache运行的用户拥有和/或写入的目录。

import os
os.environ['PYTHON_EGG_CACHE'] = '/usr/local/pylons/python-eggs' 

再次确保存在。对于Windows用户,可能是:

os.environ['PYTHON_EGG_CACHE'] = '/tmp'

或者,如果使用mod_wsgi 2.0,也可以使用WSGIPythonEggs指令用于在嵌入模式下运行的应用程序,或者在使用守护进程模式时使用WSGIDaemonProcess指令的python-eggs选项。

请注意,您应该避免使用任何可写入任何人的目录或文件,因为这可能会危及安全性。另请注意,如果在同一个Web服务器下托管多个应用程序,它们将作为同一个用户运行,因此每个人都可以查看和修改其他文件。如果这是一个问题,您应该将应用程序托管在作为不同用户或不同系统运行的不同Web服务器上。或者,应用程序所需或更新的任何数据都应托管在一个数据库中,每个应用程序都有单独的帐户。

答案 1 :(得分:2)

听起来你没有权限写入目录。卸载pitz,然后使用-Z标签重新安装以将其安装为解压缩版本。然后,您不需要每次都提取缓存目录。这应该解决目录/权限问题。