2

I've been trying to install mysqlclient for my python 3.7.2 for quite some time now. Currently using windows 10, python 3.7.2 and wamp server 2.1

I tried using the following

1) pip install mysqlclient

2) pip install c:\mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl and everything along those lines Checked this link: Installing mysqlclient in Python 3.6 in windows

3)pip install "mysqlclient==1.3.12"

4) pip install --only-binary :all: mysqlclient

5)pip install mysql-connector-python

I tried doing all of the above using cmd (as administrator) and that failed as well.

Anyone with any sort of solution for this problem are welcome! Thank you in advance!

PS the connector installs but I still cant migrate. It gives me the following error

Traceback (most recent call last):
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\backends\mysql\base.py", line 15, in <module>
    import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    django.setup()
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\SOIS\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\SOIS\PycharmProjects\Buggie\Issues\models.py", line 8, in <module>
    from django.contrib.auth.models import User, Group
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\models\base.py", line 101, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\models\base.py", line 305, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\models\options.py", line 203, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\utils.py", line 202, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\utils.py", line 110, in load_backend
    return import_module('%s.base' % backend_name)
  File "C:\Users\SOIS\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\SOIS\PycharmProjects\Buggie\venv\lib\site-packages\django\db\backends\mysql\base.py", line 20, in <module>
    ) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

And when i try to install mysqlclient:

  ----------------------------------------
  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command c:\users\sois\appdata\local\programs\python\python37-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SOIS\\AppData\\Local\\Temp\\pi
p-install-qanlzr18\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --reco
rd C:\Users\SOIS\AppData\Local\Temp\pip-record-uak3sgkf\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying _mysql_exceptions.py -> build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,3,14,'final',0)
-D__version__=1.3.14 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\users\sois\appdata\local\programs\python\python37-32\include -Ic:\users\sois\appdata\local\progra
ms\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\
BuildTools\VC\Tools\MSVC\14.16.27023\ATLMFC\Include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0
\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NET
FXSDK\4.6.1\include\um" /Tc_mysql.c /Fobuild\temp.win32-3.7\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\users\sois\appdata\local\programs\python\python37-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SOIS\\AppData\\Local\\Temp\\pip-install-qanlzr18\\mysq
lclient\\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\SOIS\AppData
\Local\Temp\pip-record-uak3sgkf\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\SOIS\AppData\Local\Temp\pip-install-qanlzr18\mysqlc
lient\

PS: I've already installed the latest visual studio build tools (2017)

Kaushal Sharma
  • 91
  • 1
  • 11
  • Installing `mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl ` isn't going to work on Python 3.7 - as `cp36` suggests in the filename, it's for Python 3.6. If you want to use `mysqlconnector-python` instead of Django, then you need to update the `ENGINE` in your `DATABASES` setting ([docs](https://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html)). – Alasdair Jan 02 '19 at 20:28
  • Are you running 32 bit Python? There is are wheels for the latest release [1.3.14](https://pypi.org/project/mysqlclient/1.3.14/#files), but they are only for Python 3.6 and 3.7 on 64-bit Windows. Perhaps you could [try re-installing] Python, but choose one of the `x86-64` options. – Alasdair Jan 02 '19 at 20:35
  • I tried installing a different version but I still end up getting the same error. I tried with python 3.7.1 32 bit and 64 bit. python 3.7.2 32 bit and 64 bit and also with python 2.7 32&64 bit. – Kaushal Sharma Jan 03 '19 at 08:54
  • Giving a long list of things that didn’t work doesn’t gives us enough information to help you. Focus on one combination that should work (e.g. Python 3.7 (64 bit), and mysqlclient 1.3.14), show the exact commands you ran and the full error message. – Alasdair Jan 03 '19 at 09:12

0 Answers0