您的位置:首页 > 编程语言 > Python开发

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

2010-05-07 23:16 381 查看

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

Posted by alex in Errors at 2:07 PM

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:

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

1
httpd.conf:LoadModule env_module modules/mod_env.so
2
httpd.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:

1
SetEnv 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:

1
SetHandler python-program
2
PythonHandler django.core.handlers.modpython
3
SetEnv DJANGO_SETTINGS_MODULE settings
4
SetEnv PYTHON_EGG_CACHE /tmp
5
PythonOption django.root /some-directory
6
PythonDebug On
7
PythonPath
"['/var/www/sites/django-project'] + sys.path"
Now your Python Eggs have a home that is not in root’s home directory
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐