0

i try to install my website on a webserver which is in CentOS 7 with Django 2.0.6 and Python 3.6.

I installed : mysql-connector = 2.1.6, mysql-connector-python = 8.0.11, MySQL-python = 1.2.5, mysqlclient = 1.3.12, PyMySQL = 0.8.1

And when i run this command :

python3.6 manage.py migrate

I have this error :

  File "MYPYTHONPATH/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 1.2.5

But in the base.py file :

try:
   import MySQLdb as Database
except ImportError as err:
raise ImproperlyConfigured(
    'Error loading MySQLdb module.\n'
    'Did you install mysqlclient?'
) from err

from MySQLdb.constants import CLIENT, FIELD_TYPE                # isort:skip
from MySQLdb.converters import conversions                      # isort:skip

# Some of these import MySQLdb, so import them after checking if it's installed.
from .client import DatabaseClient                          # isort:skip
from .creation import DatabaseCreation                      # isort:skip
from .features import DatabaseFeatures                      # isort:skip
from .introspection import DatabaseIntrospection            # isort:skip
from .operations import DatabaseOperations                  # isort:skip
from .schema import DatabaseSchemaEditor                    # isort:skip
from .validation import DatabaseValidation                  # isort:skip

version = Database.version_info
if version < (1, 3, 3):
    raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)

I dont understand what can i do for resolving this kind of problem ! I hope someone can help me on =)

DalinDad
  • 103
  • 1
  • 14
  • Well the error already says it: you have to upgrade `mysqlclient`. So `pip install --upgrade mysqlclient-python`. – Willem Van Onsem Jun 12 '18 at 14:41
  • Why have you installed all these different MySQL libraries? You only need one, probably mysqlclient. Uninstall the others. – Daniel Roseman Jun 12 '18 at 14:42
  • Furthermore are you sure that you installed this in a (possible) virtual environment? – Willem Van Onsem Jun 12 '18 at 14:42
  • @WillemVanOnsem ` Could not find a version that satisfies the requirement mysqlclient-python (from versions: ) No matching distribution found for mysqlclient-python` – DalinDad Jun 12 '18 at 14:58
  • @WillemVanOnsem I listed all mysql librairie of my virtualenv python3.6 – DalinDad Jun 12 '18 at 14:59
  • @DalinDad: yes, but do you use the virtual env when you run `manage.py`? Otherwise it will fallback to your global env. – Willem Van Onsem Jun 12 '18 at 15:00
  • @DanielRoseman I have this error know `python3.6/site-packages/django/db/backends/mysql/base.py", line 22, in from MySQLdb.constants import CLIENT, FIELD_TYPE # isort:skip ModuleNotFoundError: No module named 'MySQLdb.constants'` – DalinDad Jun 12 '18 at 15:02
  • @WillemVanOnsem Yes. `(venv-site_cnr-python3.6) [X@X]$ which python3.6` i have `/PATHTOMYENV/venv-site_cnr-python3.6/bin/python3.6` – DalinDad Jun 12 '18 at 15:05

1 Answers1

0

Okay, i solved it with the answer of this thread.

No module named MySQLdb

pip install PyMySQL

and then add this two lines to your Project/Project/init.py

import pymysql
pymysql.install_as_MySQLdb()

Works on WIN and python 3.3+

DalinDad
  • 103
  • 1
  • 14