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

前端 未结 23 1034
夕颜
夕颜 2020-12-02 10:51

The problem Im facing while trying to connect to database for mysql. I have also given the database settings that i have used.

 Traceback (most recent call l         


        
相关标签:
23条回答
  • 2020-12-02 11:40

    try:

    pip install mysqlclient
    

    I recommend to use it in a virtual environment.

    0 讨论(0)
  • 2020-12-02 11:41

    I wasted a lot of time on this. Turns out that the default database library is not supported for Python 3. You have to use a different one.

    0 讨论(0)
  • 2020-12-02 11:42

    If you are using pyhton version 3.4 or above. you have to install

    sudo apt-get install python3-dev libmysqlclient-dev 
    

    in terminal. then install pip install mysqlclient on your virtual env or where you installed pip.

    0 讨论(0)
  • 2020-12-02 11:43

    if the error looks like this

    django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module:
    dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: 
    /usr/local/opt/mysql/lib/libmysqlclient.20.dylib
    Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so
    

    then try :

    pip install python-mysqldb
    
    0 讨论(0)
  • 2020-12-02 11:45

    Seems like you don't have permission to the Python folder. Try sudo chown -R $USER /Library/Python/2.7

    0 讨论(0)
提交回复
热议问题