ExtractionError: Can’t extract file(s) to egg cache, [Errno 13] Permission denied: ‘/root/.python-eggs’

来源:互联网 发布:网站商城源码 编辑:程序博客网 时间:2024/04/28 11:00

1

I received an error when configuring a Django run site for the first time. The setup included installing and configuring some items I am not so familiar with such as mod_python, Django, and other Python items. I finally started making some progress and when I initially launched a test site I received the below errors in the debug output.

Short Error: ExtractionError: Can’t extract file(s) to egg cache

 

That was the portion at the very top of the error followed by the below output which pointed in the right direction for an easy fix which is noted below.

Apache mod_python Long Error Regarding Python Eggs:

01ExtractionError: Can't extract file(s) to egg cache
02 
03The following error occurred while trying to extract file(s) to the Python egg
04cache:
05 
06[Errno 13] Permission denied: '/root/.python-eggs'
07 
08The Python egg cache directory is currently set to:
09 
10/root/.python-eggs
11 
12Perhaps your account does not have write access to this directory?  You can
13change the cache directory by setting the PYTHON_EGG_CACHE environment
14variable to point to an accessible directory.

So what this appeared to be telling me was that the mod_python configuration I had just configured was attempting to write some sort of output to root’s home directory from the apache user. I had seen suggested that you might just touch the file .python_eggs in root’s home directory however this would not be the proper method to resolve this issue for security reasons. Since the /tmp directory allows any user to write to it already its a safe bet to put .python_eggs there. If anyone that reads this has a better location it still seems like /tmp/.python_eggs is not the best place for that file but I was unable to verify there was an issue storing it there and many others suggest that is a good place.

Verify Apache mod_env Installed:

Make sure that the mod_env Apache module is installed. You can do so by looking at your httpd.conf file and making sure it has configuration lines similar to the below.

1httpd.conf:LoadModule env_module modules/mod_env.so
2httpd.conf:LoadModule setenvif_module modules/mod_setenvif.so

Modify Django Project Apache Configuration:

The following line needs to be added to the site configuration for the project using Apache’s mod_python. This may be able to be set on a global level but I did not test that and instead used it directly in the section that specifically uses it.

Apache Directory Configuration Line For Pythin Eggs Output:

1SetEnv PYTHON_EGG_CACHE /tmp

So now my complete Django Apache project configuration looked similar to the below.

Django Project Apache Configuration With PYTHON_EGG_CACHE Environment Variable Set:

1SetHandler python-program
2PythonHandler django.core.handlers.modpython
3SetEnv DJANGO_SETTINGS_MODULE settings
4SetEnv PYTHON_EGG_CACHE /tmp
5PythonOption django.root /some-directory
6PythonDebug On
7PythonPath "['/var/www/sites/django-project'] + sys.path"

Now your Python Eggs have a home that is not in root’s home directory

原创粉丝点击