0

Everytime I run the command (pip install mysqlclient) I get this error:

  ERROR: Command errored out with exit status 1:

     command: 'c:\users\nicko\envs\py1\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\nicko\\AppData\\Local\\Temp\\pip-install-av2k0hkf\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\nicko\\AppData\\Local\\Temp\\pip-install-av2k0hkf\\mysqlclient\\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\nicko\AppData\Local\Temp\pip-record-dbm3hthv\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\nicko\envs\py1\include\site\python3.8\mysqlclient'
         cwd: C:\Users\nicko\AppData\Local\Temp\pip-install-av2k0hkf\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.8
    creating build\lib.win32-3.8\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb
    creating build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.8
    creating build\temp.win32-3.8\Release
    creating build\temp.win32-3.8\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" "-Id:\a\jan10python\new folder\include" "-Id:\a\jan10python\new folder\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_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\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\nicko\envs\py1\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\nicko\\AppData\\Local\\Temp\\pip-install-av2k0hkf\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\nicko\\AppData\\Local\\Temp\\pip-install-av2k0hkf\\mysqlclient\\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\nicko\AppData\Local\Temp\pip-record-dbm3hthv\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\nicko\envs\py1\include\site\python3.8\mysqlclient' Check the logs for full command output.

The main point above is probably the line fatal error C1083: Cannot open include file: 'mysql.h' but I have no idea what to do.

I've tried many other "solutions". Some are way too confusing. Others dont't work at all (mysql-python install error: Cannot open include file 'config-win.h', “Cannot open include file: 'config-win.h': No such file or directory” while installing mysql-python). Anyone have any ideas? Should I try installing anything and WHERE should I install it? If you have any links you can share, I'd accept any of them.

Extra: I can say that I'm pretty stupid so if you do give me an aswer, you will have to explain almost everything about it or else I'll keep asking question and you'll probably get annoyed :D Thanks.

1 Answers1

0

You are missing the mysql headers which you should install through mysql client connector installer.

Easier way would be just to install it through wheel, it should automatically use the official wheel if your python is x64 version but you can download and install unofficial compiled wheel ( you should chose download for your version of python (3.8 x86?) and install it using)

pip install some-package.whl
iklinac
  • 14,944
  • 4
  • 28
  • 30
  • 1
    I got this when dowloading the official wheel: `ERROR: mysqlclient-1.4.6-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.` I'll try the other way. –  Jan 11 '20 at 22:54
  • from what i see your python should be x86 -> mysqlclient‑1.4.6‑cp38‑cp38‑win32.whl – iklinac Jan 11 '20 at 22:56
  • Okay, I instead installed the 32 bit version and it worked. I'm going to see if I can use the 64 bit version. –  Jan 11 '20 at 22:57
  • both as pip is python module – iklinac Jan 11 '20 at 22:58
  • I am also having issues with the 64 bit version of Python 3.8/pip not accepting the unofficial wheel for 1.4.6 x64. I guess I'll try installing the headers manually. – trpt4him May 21 '20 at 13:57
  • nobody in this question had issues of pip not accepting unofficial x64 wheel with x64 version of python OP had x86( 32 bit) version – iklinac May 21 '20 at 14:08