apache2上的Django MySQLdb问题 [英] Django MySQLdb issue on apache2
问题描述
我已经在ubuntu服务器django 1.9.4和mysqlclient上安装了,我不在virtualenv下.
i've installed on an ubuntu server django 1.9.4 and mysqlclient, i'm not under virtualenv.
如果我运行manage.py shell或runserver一切正常,但是如果我尝试通过apache2和wgi则出现此错误:
If i run manage.py shell or runserver all goes right, but if i try through apache2 and wgi i got this error:
ImproperlyConfigured: Error loading MySQLdb module: this is MySQLdb version (1, 3, 7, 'final', 1), but _mysql is version (1, 2, 3, 'final', 0)
Python 3.4版
Python version 3.4
这是apache2虚拟主机配置:
This is the apache2 vhost config:
WSGIPythonPath /usr/local/lib/python3.4/dist-packages/:/home/ubuntu/www/mysite
DocumentRoot/home/ubuntu/www/mysite 错误日志$ {APACHE_LOG_DIR}/mysite.log CustomLog $ {APACHE_LOG_DIR}/access.log组合
DocumentRoot /home/ubuntu/www/mysite ErrorLog ${APACHE_LOG_DIR}/mysite.log CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIScriptAlias / /home/ubuntu/www/mysite/mysite/wsgi.py
<Directory /home/ubuntu/www/mysite/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
Require all granted
</Files>
</Directory>
解决方案:
是软件包版本错误,我使用以下命令解决了该问题:
was a packages version error, with the following commands i solved it:
sudo apt-get删除libapache2-mod-python libapache2-mod-wsgi sudo apt-get install libapache2-mod-wsgi-py3
sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi sudo apt-get install libapache2-mod-wsgi-py3
推荐答案
从错误消息中可以明显看出,您在系统上的mysql版本与MySQL-python-1.3.7不同.
It is clear from the error message that your mysql version on system differs from MySQL-python-1.3.7.
尝试卸载MySQL-python并安装1.2.3版本.
Try uninstall MySQL-python and install 1.2.3 version.
这篇关于apache2上的Django MySQLdb问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!