12

I've trawled the forums but cannot find an answer or even any documentation on this.

On running the command:

python manage.py inspectdb

I get the error:

mysqlclient 1.3.13 or newer is required; you have 0.9.3

I have tried all the suggested fixes including: -upgrading pip -installing a different wheel (32 bit instead of 64), namely mysqlclient-1.4.2-cp37-cp37m-win32.whl with the command pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl (this works fine without an error but doesn't do the job required!)

My objective is to simply connect a legacy mysql database (running inside of XAMPP and myphpadmin) to Django. I've followed the documentation which misses out the need to install mysqlclient, and have got stuck at this point.

21

This is how I fixed it.

Go to your django/db/backends/mysql installation dir. Check your path in the error message.

I'm using pipenv so my path is:

/home/username/.local/share/virtualenvs/project-env/lib/python3.7/site-packages/django/db/backends/mysql

Open file base.py and search for:

version = Database.version_info

Put a pass inside if and comment line:

raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.version)

Like this.

if version < (1, 3, 13):
   pass
   '''
   raise ImproperlyConfigured(
       'mysqlclient 1.3.13 or newer is required; you have %s.'
       % Database.__version__
   )
   '''

Save, close this file and open operations.py.

Search for:

query = query.decode(errors='replace')

and change decode to encode

query = query.encode(errors='replace')

Now, try to run the server.

3

I have had the same issue as lower version of mysqlclient was installed due to pymysql.

OS: Linux Mint 19.1

Python: 3.6.8

Django: 2.2.2

  1. Uninstall mysqlclient: pip3 uninstall mysqlclient
  2. Uninstall pymysql: pip3 uninstall pymysql
  3. Install mysqlclient: pip3 install mysqlclient
1

Instead of edit internal configuration, try to upgrade the version of mysqlclient

pip3 install -U mysqlclient
0
  1. Install wheel:

    pip install wheel

  2. Download file that you want from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

  3. Move to your Downloads directory (I guess it'll be cd Downloads)

  4. Install downloaded file with: pip install <file name>

WARNING!! You CANT edit name of downloaded .whl file. It contains some information what is required to install.

0

I had a similar issue, I was getting

"django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 1.3.12."

So I went to the C:\Users\username\Envs\env\Lib\site-packages\django\db\backends\mysql, opened base.py and changed that line...

if version < (1, 3, 13): 

to...

if version < (1, 3, 10):

which is a version lesser than mine and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["<li class=\"-item\"><a href=\"https://www.facebook.com/officialstackoverflow/\" class=\"-link\">Facebook</a></li>\r\n                    <li class=\"-item\"><a href=\"https://twitter.com/stackoverflow\" class=\"-link\">Twitter</a></li>\r\n                    <li class=\"-item\"><a href=\"https://linkedin.com/company/stack-overflow\" class=\"-link\">LinkedIn</a></li>\r\n                </ul>\r\n\r\n                <p class=\"mt-auto mb24\">\r\nsite design / logo &#169; 2019 Stack Exchange Inc; user contributions licensed under <a href=\"https://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a>\r\n                            with <a href=\"https://stackoverflow.blog/2009/06/25/attribution-required/\" rel=\"license\">attribution required</a>.\r\n                    <span id=\"svnrev\">rev&nbsp;2019.8.16.34633</span>\r\n                </p>\r\n            </div>\r\n        </div>\r\n\r\n            </footer>\r\n            <script>StackExchange.ready(function () { StackExchange.responsiveness.addSwitcher(); })</script>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works b"], "copyright__copyright__copyright": ["client 1.3.13 or newer is required; you have 1.3.12.\"\n\nSo I went to the C:\\Users\\username\\Envs\\env\\Lib\\site-packages\\django\\db\\backends\\mysql, opened base.py and changed that line...\n\nif version < (1, 3, 13): \n\nto...\n\nif version < (1, 3, 10):\n\nwhich is a version lesser than mine and it worked.\n\nYour Answer\n\nBy clicking \u201cPost Your Answer\u201d, you agree to our terms of service, privacy policy and cookie policy\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}