Задать вопрос
@AirronBark

Как решить ошибку при установке Mysqlclient в pycharm?

Боролся сегодня пол дня с установкой mysql вместо sqlite3 для проекта в django но так и не смог решить проблему:
При установке через pip возникает следующая ошибка:

Пробовал устанавливать через колеса, через терминал и настройки pycharm.

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.
  • Вопрос задан
  • 573 просмотра
Подписаться 1 Простой Комментировать
Решения вопроса 1
@alexbprofit
Junior SE
Решение для mysql
Установите сервер mysql, затем перейдите в каталог include для сервера mysql, затем скопируйте папку mysql и файлы заголовков в папку, например
C: \ Program Files (x86) \ Microsoft Visual Studio \ 2019 \ BuildTools \ VC \ Tools \ MSVC \ 14.28.29910 \ include
затем прокомментируйте в setup_windows.py в строке каталога mysqlclent client = 'mariadbclient' и раскомментируйте предыдущую строку, затем скопируйте
файл mysqlclient.lib, который хранится в каталоге lib сервера mysql в
C: \ Program Files (x86) \ Windows Kits \ 10 \ Lib \ 10.0.16299.0 \ ucrt \ x64.
это решение сработало для меня.
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
@Andy_U
На pypi.org как видно, wheel-файлы существуют лишь для 64-bit Python'а. У вас 32-bit Python... Установите 64-bit с сайта python.org, переходите на него и не мучайтесь.

Или тут инструкцию прочитайте.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
22 дек. 2024, в 20:40
10000 руб./за проект
22 дек. 2024, в 20:34
3000 руб./за проект
22 дек. 2024, в 20:12
10000 руб./за проект