python - "Can' t 将文件提取到 Egg 缓存“GAE 中出现错误

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

我安装了 Windows 7 和 Python 2.7,并安装了 setuptools。

我下载 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.

如何解决这个问题?

最佳答案

来自: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 服务器上。或者,应用程序所需或更新的任何数据都应托管在数据库中,每个应用程序具有单独的帐户。

关于python - "Can' t 将文件提取到 Egg 缓存“GAE 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24230950/

相关文章:

python - 如何覆盖 python 库的函数?

python - nose.collector 在哪里寻找测试?

google-app-engine - 如何使用 GAE 创建自动完成?

java - 如何从 Google App Engine 应用程序运行 Google Dataflow 管道?

python - AppEngine urlfetch validate_certificate=False/None 不被尊重

python - 使用for循环python3解析文件时出现UnicodeDecodeError错误

python - 如何将unicode字符串转换为对应的ascii字符串?

python - 整数值之间的条件前向填充

python - Seaborn 图表收敛于同一点不可见

python - 在Python中调用IDL脚本