Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

I am using windows 10 command line for a django project using python34 however, I am facing difficulties with SQL.

I have already installed mysqlclient using pip install mysqlclient==1.3.5 and located the file to make sure I was not delusional. I then ran python manage.py migrate to migrate the tables to the SQL database (I am using phpmyadmin). However when the command returned with...

 File "C:\Users\user\env\lib\site-packages\django\db\backends\mysql\base.py", line 30, in <module>     'Did you install mysqlclient or MySQL-python?' % e django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python? 

I am aware that questions like these already exist, but not one solution seems to have made any impact on attempts. Thank you in advance.

回答1:

Use the below command to solve your issue,

pip install mysql-python apt-get install python3-mysqldb libmysqlclient-dev python-dev 

Works on Debian



回答2:

pip install pymysql 

Then, edit the __init__.py file in your project origin dir(the same as settings.py)

add:

import pymysql  pymysql.install_as_MySQLdb() 


回答3:

Use the below command to solve your issue,

pip install mysql-python 

And avoid posting questions before a proper search, this issues been questioned and answered, please refer below link

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb



回答4:

Try to start apache and mysql on xampp. It works for me.



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