我注意到每当我在我的django项目上启用数据库设置时(开始注意到我的问题中的趋势?)它会给我一个内部服务器错误.将数据库设置设置为空白会使错误消失.以下是它输出的apache错误日志.
mod_wsgi (pid=770): Exception occurred processing WSGI script '/Users/teifionjordan/rob2/apache/django.wsgi'. Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/core/handlers/wsgi.py", line 239, in __call__ response = self.get_response(request) File "/Library/Python/2.5/site-packages/django/core/handlers/base.py", line 67, in get_response response = middleware_method(request) File "/Library/Python/2.5/site-packages/django/contrib/sessions/middleware.py", line 9, in process_request engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) File "/Library/Python/2.5/site-packages/django/contrib/sessions/backends/db.py", line 2, infrom django.contrib.sessions.models import Session File "/Library/Python/2.5/site-packages/django/contrib/sessions/models.py", line 4, in from django.db import models File "/Library/Python/2.5/site-packages/django/db/__init__.py", line 16, in backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, ['']) File "/Library/Python/2.5/site-packages/django/db/backends/mysql/base.py", line 10, in import MySQLdb as Database File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line 19, in File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 4, in __bootstrap__ File "/Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 841, in resource_filename self, resource_name File "/Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 1310, in get_resource_filename self._extract_resource(manager, self._eager_to_zip(name)) File "/Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 1332, in _extract_resource self.egg_name, self._parts(zip_path) File "/Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 921, in get_cache_path self.extraction_error() File "/Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 887, in extraction_error raise err 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 20] Not a directory: '/Library/WebServer/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp' 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.
这是django.wsgi文件
import os import sys os.environ['DJANGO_SETTINGS_MODULE'] = 'rob2.settings' sys.path.append('/Users/teifionjordan') import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
我有几个其他脚本都可以连接到mysql数据库,如果我运行教程服务器,那么它会正确显示管理面板.我曾尝试更改鸡蛋的环境变量,但仍然没有任何变化.
您需要设置PYTHON_EGG_CACHE
环境变量.Apache/mod_wsgi试图将egg提取到Apache没有写入权限的目录中......或者不存在.
这里的Django文档对此进行了解释.
是否/Library/WebServer/.python-eggs
存在?你的Apache配置文件是什么样的?