0

when running that command python manage.py runserver I get this error

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

I try to pip install mysqlclient and get this

Command "C:\Users\xavi6\PycharmProjects\LES\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\xavi6\\App
Data\\Local\\Temp\\pip-install-8q8y5ra6\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\
n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\xavi6\AppData\Local\Temp\pip-record-zvgp3gov\inst
all-record.txt --single-version-externally-managed --compile --install-headers C:\Users\xavi6\PycharmProjects\LES\venv\include\site\py
thon3.7\mysqlclient" failed with error code 1 in C:\Users\xavi6\AppData\Local\Temp\pip-install-8q8y5ra6\mysqlclient\

I'm using pycharm and I think I try everything. How can I resolve this error?

William Miller
  • 9,839
  • 3
  • 25
  • 46
  • Is this a new project? which Django version? What is your database configuration on the `settings.py` on your app – DarK_FirefoX Mar 28 '20 at 23:57
  • I change that to mysql, is the only change i do, yes its the last version of django and is a new project. `DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'django_test', 'USER': 'root', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '3306' } }` – xavi6696 Mar 29 '20 at 03:45
  • i tried `pip install --upgrade setuptools` too – xavi6696 Mar 29 '20 at 03:54
  • Try `sudo apt-get install libmysqlclient-dev` to install python dependencies and then `pip install mysqlclient`. More [Here](https://stackoverflow.com/questions/19189813/setting-django-up-to-use-mysql) – DarK_FirefoX Mar 29 '20 at 13:38

1 Answers1

0

have you installed pip install mysqlclient

Then edit init.py

import pymysql

pymysql.install_as_MySQLdb()

and then let me know it worked or not.Happy coding

  • i tried and i got an error, i do `pip install mysqlclient` and got that error `Command "C:\Users\xavi6\PycharmProjects\LES\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\xavi6\\App Data\\Local\\Temp\\pip-install-_k6zdj2w\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\ n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record ` – xavi6696 Mar 29 '20 at 16:21
  • ` C:\Users\xavi6\AppData\Local\Temp\pip-record-vie_6885\inst all-record.txt --single-version-externally-managed --compile --install-headers C:\Users\xavi6\PycharmProjects\LES\venv\include\site\py thon3.7\mysqlclient" failed with error code 1 in C:\Users\xavi6\AppData\Local\Temp\pip-install-_k6zdj2w\mysqlclient\ ` – xavi6696 Mar 29 '20 at 16:22
  • and in init.py says that theres no ` no module named pymysql ` – xavi6696 Mar 29 '20 at 16:24