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

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.