Search code examples
pythonmysqldjangophpmyadmin

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


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.


Solution

  • 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()