A
A
AirronBark2021-12-07 19:28:35
MySQL
AirronBark, 2021-12-07 19:28:35

How to solve error while installing Mysqlclient in pycharm?

Today I struggled for half a day with installing mysql instead of sqlite3 for a project in django, but I could not solve the problem:
When installing via pip, the following error occurs:

I tried installing via wheels, via the terminal and pycharm settings.

Collecting mysqlclient
  Using cached mysqlclient-2.1.0.tar.gz (87 kB)
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py): started
  Building wheel for mysqlclient (setup.py): finished with status 'error'
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient: started
    Running setup.py install for mysqlclient: finished with status 'error'

DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
  ERROR: Command errored out with exit status 1:
   command: 'C:\Program Files (x86)\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ivan W\\AppData\\Local\\Temp\\pycharm-packaging\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ivan W\\AppData\\Local\\Temp\\pycharm-packaging\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Ivan W\AppData\Local\Temp\pip-wheel-xdfxz6ef'
       cwd: C:\Users\Ivan W\AppData\Local\Temp\pycharm-packaging\mysqlclient\
  Complete output (29 lines):
  running bdist_wheel
  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\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
  D:\MVisisal studio\studio\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 "-IC:\Program Files (x86)\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files (x86)\MariaDB\MariaDB Connector C\include" "-IC:\Program Files (x86)\Python38-32\include" "-IC:\Program Files (x86)\Python38-32\include" "-ID:\MVisisal studio\studio\VC\Tools\MSVC\14.29.30037\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj
  _mysql.c
  MySQLdb/_mysql.c(29): fatal error C1083: ЌҐ г¤ Ґвбп ®вЄалвм д ©« ўЄ«о祭ЁҐ: mysql.h: No such file or directory,
  error: command 'D:\\MVisisal studio\\studio\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient
    ERROR: Command errored out with exit status 1:
     command: 'C:\Program Files (x86)\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ivan W\\AppData\\Local\\Temp\\pycharm-packaging\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ivan W\\AppData\\Local\\Temp\\pycharm-packaging\\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\Ivan W\AppData\Local\Temp\pip-record-hdm5wlxp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Program Files (x86)\Python38-32\Include\mysqlclient'
         cwd: C:\Users\Ivan W\AppData\Local\Temp\pycharm-packaging\mysqlclient\
    Complete output (31 lines):
    running install
    C:\Users\Ivan W\AppData\Roaming\Python\Python38\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    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\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
    D:\MVisisal studio\studio\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 "-IC:\Program Files (x86)\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files (x86)\MariaDB\MariaDB Connector C\include" "-IC:\Program Files (x86)\Python38-32\include" "-IC:\Program Files (x86)\Python38-32\include" "-ID:\MVisisal studio\studio\VC\Tools\MSVC\14.29.30037\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: ЌҐ г¤ Ґвбп ®вЄалвм д ©« ўЄ«о祭ЁҐ: mysql.h: No such file or directory,
    error: command 'D:\\MVisisal studio\\studio\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Program Files (x86)\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ivan W\\AppData\\Local\\Temp\\pycharm-packaging\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ivan W\\AppData\\Local\\Temp\\pycharm-packaging\\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\Ivan W\AppData\Local\Temp\pip-record-hdm5wlxp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Program Files (x86)\Python38-32\Include\mysqlclient' Check the logs for full command output.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alexbprofit, 2021-12-07
@AirronBark

Solution for mysql
Install mysql server then go to include directory for mysql server then copy mysql folder and header files to folder like
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\ 14.28.29910\include
then comment in setup_windows.py under directory line mysqlclent client='mariadbclient' and uncomment the previous line then copy
mysqlclient.lib file which is stored in mysql server lib directory to
C:\Program Files (x86)\Windows kits\10\lib\10.0.16299.0\ucrt\x64.
this solution worked for me.

A
Andy_U, 2021-12-07
@Andy_U

As you can see on pypi.org , wheel files only exist for 64-bit Python. You have 32-bit Python... Install 64-bit from python.org, go to it and don't worry.
Or read the instructions here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question