apache2 上的 Django MySQLdb 问题 [英] Django MySQLdb issue on apache2

查看:29
本文介绍了apache2 上的 Django MySQLdb 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装在 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.logCustomLog ${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须藤 apt-get 安装 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆