LoginSignup
7
3

More than 3 years have passed since last update.

pip install mysqlclient でハマった

Posted at

結論

python 64bit版を入れると解消した。(ような気がする)

エラー

pip install mysqlclientするとエラーが出た。

> pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.4.6.tar.gz (85 kB)
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\parkh\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-jh98ljrf\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-jh98ljrf\\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\parkh\AppData\Local\Temp\pip-record-iqwk0kn0\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\parkh\appdata\local\programs\python\python37-32\Include\mysqlclient'
         cwd: C:\Users\parkh\AppData\Local\Temp\pip-install-jh98ljrf\mysqlclient\
    Complete output (24 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.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
    running build_ext
    building 'MySQLdb._mysql' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\parkh\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-jh98ljrf\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-jh98ljrf\\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\parkh\AppData\Local\Temp\pip-record-iqwk0kn0\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\parkh\appdata\local\programs\python\python37-32\Include\mysqlclient' Check the logs for full command output.

C++ Build Tools入れてみる

image.png

> pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.4.6.tar.gz (85 kB)
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\parkh\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-pk832a_j\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-pk832a_j\\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\parkh\AppData\Local\Temp\pip-record-899z4ym7\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\parkh\appdata\local\programs\python\python37-32\Include\mysqlclient'
         cwd: C:\Users\parkh\AppData\Local\Temp\pip-install-pk832a_j\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.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
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -Ic:\users\parkh\appdata\local\programs\python\python37-32\include -Ic:\users\parkh\appdata\local\programs\python\python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\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.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: include ファイルを開けません。'mysql.h':No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\parkh\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-pk832a_j\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\parkh\\AppData\\Local\\Temp\\pip-install-pk832a_j\\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\parkh\AppData\Local\Temp\pip-record-899z4ym7\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\parkh\appdata\local\programs\python\python37-32\Include\mysqlclient' Check the logs for full command output.

mysql client入れてみる

image.png
image.png
image.png
image.png

これでもダメだった。

python 64bitが入ってないよって言われてる気がする

python 32bitをアンインストールして、python 64インストールしてみた。
解消しない・・

念のため再起動してみた。

> pip install pymysql
Collecting pymysql
  Using cached https://files.pythonhosted.org/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl
Installing collected packages: pymysql
Successfully installed pymysql-0.9.3

ついに成功!

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3