Django MySQLdb issue on apache2

浪尽此生 提交于 2019-12-08 13:14:38

问题


i've installed on an ubuntu server django 1.9.4 and mysqlclient, i'm not under virtualenv.

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 version 3.4

This is the apache2 vhost config:

WSGIPythonPath /usr/local/lib/python3.4/dist-packages/:/home/ubuntu/www/mysite

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>

SOLUTION:

was a packages version error, with the following commands i solved it:

sudo apt-get remove libapache2-mod-python libapache2-mod-wsgi sudo apt-get install libapache2-mod-wsgi-py3


回答1:


It is clear from the error message that your mysql version on system differs from MySQL-python-1.3.7.

Try uninstall MySQL-python and install 1.2.3 version.



来源:https://stackoverflow.com/questions/36502772/django-mysqldb-issue-on-apache2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!