title: Python Error: django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
body: <p>I'm trying to run a Django application, which requires a MySql database,<br>
  I have MySql installed and it works fine with other languages.<br>
  I'm using a virtual environment to run the Django project,<br>
  But I'm facing issues with setting up the MySql configuration with the following python libraries -
  <strong>pymysql and mysqlclient</strong></p>
  
  <p><strong>Project structure -</strong><br></p>
  
  <p><a href="https://i.stack.imgur.com/3NNts.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3NNts.png" alt="enter image description here"></a></p>
  
  <p><br>There seems to be a version mismatch,<br>
  <strong>Following is the full error -</strong></p>
  
  <pre><code>(env) Aniruddhas-MacBook-Pro:djangocrashcourse-master aniruddhanarendraraje$ python manage.py runserver
  Watching for file changes with StatReloader
  Exception in thread django-main-thread:
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
      self.run()
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
      self._target(*self._args, **self._kwargs)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
      fn(*args, **kwargs)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
      autoreload.raise_last_exception()
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
      raise _exception[1]
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 337, in execute
      autoreload.check_errors(django.setup)()
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
      fn(*args, **kwargs)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
      app_config.import_models()
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
      self.models_module = import_module(models_module_name)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/djangocrashcourse-master/posts/models.py", line 5, in &lt;module&gt;
      class Posts(models.Model):
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/models/base.py", line 117, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/models/base.py", line 321, in add_to_class
      value.contribute_to_class(cls, name)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/models/options.py", line 204, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/__init__.py", line 28, in __getattr__
      return getattr(connections[DEFAULT_DB_ALIAS], item)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/utils.py", line 201, in __getitem__
      backend = load_backend(db['ENGINE'])
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend
      return import_module('%s.base' % backend_name)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 36, in &lt;module&gt;
      raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
  django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8HTNS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8HTNS.png" alt="enter image description here"></a></p>
  
  <p><strong>Issue -</strong></p>
  
  <p><code>mysqlclient 1.4.4</code> is already installed, still the error. <br>
  <code>pymysql</code> is of version <code>0.9.3</code>, I tried uninstalling it and running,<br>
  But it requires me to install it back.</p>
  
  <p><strong>I've tried the following -</strong><br></p>
  
  <pre><code>pip uninstall pymysql
  pip uninstall mysqlclient
  </code></pre>
  
  <ol>
  <li>then installing only pymysql and running<br></li>
  <li>installing only mysqlclient and running<br></li>
  <li>installing both pymysql and mysqlclient and running</li>
  </ol>
  
  <p><strong>I'm trying to run this project for study -</strong><br>
  <a href="https://github.com/bradtraversy/djangocrashcourse" rel="nofollow noreferrer">https://github.com/bradtraversy/djangocrashcourse</a></p>
  
  <p><strong>Steps to check running the virtual env first and then running the manage/py file -</strong></p>
  
  <pre><code>Aniruddhas-MacBook-Pro:python_django aniruddhanarendraraje$ ls
  djangocrashcourse-master        env                             mysite
  Aniruddhas-MacBook-Pro:python_django aniruddhanarendraraje$ source ./env/bin/activate
  (env) Aniruddhas-MacBook-Pro:python_django aniruddhanarendraraje$ cd djangocrashcourse-master/
  (env) Aniruddhas-MacBook-Pro:djangocrashcourse-master aniruddhanarendraraje$ pip list
  Package     Version
  ----------- -------
  Django      2.2.4  
  mysqlclient 1.4.4  
  pip         19.2.3 
  pytz        2019.2 
  setuptools  41.2.0 
  sqlparse    0.3.0  
  wheel       0.33.6 
  (env) Aniruddhas-MacBook-Pro:djangocrashcourse-master aniruddhanarendraraje$ python manage.py runserver
  Watching for file changes with StatReloader
  Exception in thread django-main-thread:
  Traceback (most recent call last):
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 15, in &lt;module&gt;
      import MySQLdb as Database
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in &lt;module&gt;
      from . import _mysql
  ImportError: dlopen(/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
    Referenced from: /Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
    Reason: image not found
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
      self.run()
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
      self._target(*self._args, **self._kwargs)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
      fn(*args, **kwargs)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
      autoreload.raise_last_exception()
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
      raise _exception[1]
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 337, in execute
      autoreload.check_errors(django.setup)()
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
      fn(*args, **kwargs)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
      app_config.import_models()
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
      self.models_module = import_module(models_module_name)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/djangocrashcourse-master/posts/models.py", line 5, in &lt;module&gt;
      class Posts(models.Model):
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/models/base.py", line 117, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/models/base.py", line 321, in add_to_class
      value.contribute_to_class(cls, name)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/models/options.py", line 204, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/__init__.py", line 28, in __getattr__
      return getattr(connections[DEFAULT_DB_ALIAS], item)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/utils.py", line 201, in __getitem__
      backend = load_backend(db['ENGINE'])
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend
      return import_module('%s.base' % backend_name)
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/importlib/__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
    File "/Users/aniruddhanarendraraje/Documents/work/pocs/pythonBasics/python_django/env/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 20, in &lt;module&gt;
      ) from err
  django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
  Did you install mysqlclient?
  </code></pre>