Search code examples
pythonmysqldjangopythonanywhere

Pythonanywhere Django app does not work with MySql


What do we have:

  1. Django app hosted on Pythonanywhere with sqlite db initialized
  2. MySql DB activated on Pythonanywhere (it provided me with db name, pasword and host - everything that I need to setup settings.py)
  3. pip install mysqlclient finished successfully
  4. python manage.py makemigrations - DONE
  5. python manage.py migrate - DONE
  6. mysql console on Pythonanywhere shows all my tables created
  7. but restarting app causes pythonanywhere error page and link to error log

2020-08-15 17:22:56,536: Error running WSGI application
2020-08-15 17:22:56,569: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
2020-08-15 17:22:56,569: Did you install mysqlclient?

So the question is how could it be possible? As i got it right migrations are used mysqlclient to manipulate DB, how can it be not installed?

Might be someone did face with similar issue?


Solution

  • you need to install mysql client, but that might also throw an error, so you need to install it using its wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient and keep installing every wheel incase an error occurs.