如何在Mac上设置PYTHON_EGG_CACHE环境变量?

时间:2012-02-02 04:02:14

标签: python mysql django mysql-python

我正在尝试将Django设置为使用MySQL。当我输入localhost/mysite

时,我收到以下错误
ExtractionError at /
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: '/Library/WebServer/.python-eggs'

The Python egg cache directory is currently set to:

  /Library/WebServer/.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.

从错误消息我知道我必须将PYTHON_EGG_CACHE环境变量更改为指向Apache可以访问的目录。我尝试将以下内容添加到httpd.conf

SetEnv PYTHON_EGG_CACHE /var/www
<Directory /var/www>
    Order deny,allow
    Allow from all
</Directory>

也只是SetEnv PYTHON_EGG_CACHE /var/wwwbashrc,但似乎没有解决问题的方法。关于我可能做错什么的任何建议?

注意:www是我创建的文件夹

2 个答案:

答案 0 :(得分:6)

也可以尝试在wsgi脚本中设置egg cache目录,

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

从这里可以找到 http://code.google.com/p/modwsgi/wiki/ApplicationIssues

答案 1 :(得分:1)

根据您之前的问题,您正在使用WSGI。您需要WSGIPythonEggsWSGIDaemonProcesspython-eggs选项。