"Can't extract file(s) to egg cache" error in GAE
Question: I have Windows 7 and Python 2.7 with setuptools installed.

After i download pitz module (easy_install pitz), Google App Engine stop
working:

    
    
    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.
    

How to solve this issue?


Answer: from: <https://code.google.com/p/modwsgi/wiki/ApplicationIssues>

To avoid this particular problem you can set the `PYTHON_EGG_CACHE` cache
environment variable at the start of the WSGI application script file. The
environment variable should be set to a directory which is owned and/or
writable by the user that Apache runs as.

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

Again, make sure this exists. For Windows users, maybe something like:

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

Alternatively, if using mod_wsgi 2.0, one could also use the WSGIPythonEggs
directive for applications running in embedded mode, or the `python-eggs`
option to the WSGIDaemonProcess directive when using daemon mode.

Note that you should refrain from ever using directories or files which have
been made writable to anyone as this could compromise security. Also be aware
that if hosting multiple applications under the same web server, they will all
run as the same user and so it will be possible for each to both see and
modify each others files. If this is an issue, you should host the
applications on different web servers running as different users or on
different systems. Alternatively, any data required or updated by the
application should be hosted in a database with separate accounts for each
application.

