pkg_resources.ExtractionError: Can't extract file(s) to egg cache: [Errno 13] Permission denied:
Question: So, I've been battling this ongoing problem for days and here's my latest
dead-end:

I wanted to uninstall cx_Oracle to start fresh. I found
[this](http://stackoverflow.com/questions/922323/how-do-i-deactivate-an-egg)
that said the way to do that was to delete the egg file.

So I did:

    
    
    rm -rf /Users/xxx/.python-eggs/cx_Oracle-5.1.3-py2.7-macosx-10.8-x86_64.egg-tmp/
    

Which I now see was a total reading comprehension failure on my part, but
what's done is done.

Then I tried to run the script and got:

    
    
     File "time_reporting.py", line 31, in <module>
        import cx_Oracle
      File "build/bdist.macosx-10.8-x86_64/egg/cx_Oracle.py", line 7, in <module>
      File "build/bdist.macosx-10.8-x86_64/egg/cx_Oracle.py", line 4, in __bootstrap__
      File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 951, in resource_filename
        err.manager        = self
      File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 1647, in get_resource_filename
        def get_importer(path_item):
      File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 1677, in _extract_resource
        except ImportError:
      File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 1017, in get_cache_path
        Resource providers should call this method ONLY after successfully
      File "build/bdist.macosx-10.8-x86_64/egg/pkg_resources.py", line 997, in extraction_error
    
    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:
    
      [Errno 13] Permission denied: '/Users/xxx/.python-eggs/cx_Oracle-5.1.3-py2.7-macosx-10.8-x86_64.egg-tmp'
    
    The Python egg cache directory is currently set to:
    
      /Users/xxx/.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.
    

Now I have no idea what to do. Python 2.7.8, OSX 10.8.5


Answer: UNIX file permissions and ownerships of the target directories are incorrect.
Most likely you have installed stuff as root, making those directories root
owned.

[Do not install packages as root in
Python](http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-
installation-of-python-software-with-virtualenv/), unless you really know what
you are doing.

[Use UNIX chmod and chown commands to fix directory
permissions](http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/)

... or remove directories with sudo and after this reinstall the packages
without sudo:

    
    
    sudo rm -rf /Users/xxx/.python-eggs/
    

