Install MySQL Client in Django Show Error
Question:
Hi I am trying to install Mysqlclient
in Django and I got this message
collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Complete output from command 'c:usersusermo~1virtua~1tmsv2_~2scriptspython.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\userMO~1\AppData\Local\Temp\pip-install-vzfx29bg\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:UsersuserMO~1AppDataLocalTemppip-wheel-rd_6y67h' --python-tag cp37:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating buildlib.win32-3.7
creating buildlib.win32-3.7MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.7MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcompat.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.7MySQLdb
creating buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.7MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
creating buildtemp.win32-3.7
creating buildtemp.win32-3.7Release
creating buildtemp.win32-3.7ReleaseMySQLdb
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.7ReleaseMySQLdb/_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\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: 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
ERROR: Complete output from command 'c:usersusermo~1virtua~1tmsv2_~2scriptspython.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\userMO~1\AppData\Local\Temp\pip-install-vzfx29bg\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersuserMO~1AppDataLocalTemppip-record-ea_7lykdinstall-record.txt' --single-version-externally-managed --compile --install-headers 'c:usersusermo~1virtua~1tmsv2_~2includesitepython3.7mysqlclient':
ERROR: running install
running build
running build_py
creating build
creating buildlib.win32-3.7
creating buildlib.win32-3.7MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.7MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcompat.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.7MySQLdb
creating buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.7MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
creating buildtemp.win32-3.7
creating buildtemp.win32-3.7Release
creating buildtemp.win32-3.7ReleaseMySQLdb
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:Program Files
(x86)MySQLMySQL Connector C 6.1includemariadb" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.7ReleaseMySQLdb/_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\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command "'c:usersusermo~1virtua~1tmsv2_~2scriptspython.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\userMO~1\AppData\Local\Temp\pip-install-vzfx29bg\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersuserMO~1AppDataLocalTemppip-record-ea_7lykdinstall-record.txt' --single-version-externally-managed --compile --install-headers 'c:usersusermo~1virtua~1tmsv2_~2includesitepython3.7mysqlclient'" failed with error code 1 in C:UsersuserMO~1AppDataLocalTemppip-install-vzfx29bgmysqlclient
I already tried several way
pip install opencv-contrib-python
(can install no work)
pip install mysqlclient==1.3.12
(show same error)
- I install the mycsqlclient from Wheel Link (show this error
mysqlclient-1.4.2-cp38-cp38m-win_amd64.whl is not a supported wheel on this platform.
)
My python version is: 3.7.3
(I come from desktop environment and while I read the Django, its say “Ridiculously fast” but now for MySQL connection problem took 4 days already).
Answers:
I got the same error when I try to install mysqlclient in windows. after much time spent in this error. I found a result in the result install the latest visual studio and visual studio build tools. if programmer and only work on coding then transfer windows to ubuntu.i transfer on Ubuntu and enjoy coding
It seems like your Build Tools cannot handle some .h
files. You can use unofficial precompiled package database to get already compiled mysqlclient
.
After downloading it run
pip install name-of-whl-file.whl
If the python+win version of whl file fails to install, try using another version. Always works for me if Build Tools fail.
You have downloaded the wrong wheel. The error message says you tried to install mysqlclient-1.4.2-cp38-cp38m-win_amd64.whl
, which is for Python 3.8.
Since you are using Python 3.7, you should use either mysqlclient‑1.4.2‑cp37‑cp37m‑win32.whl
or mysqlclient‑1.4.2‑cp37‑cp37m‑win_amd64.whl
depending on whether you have installed 32-bit or 64-bit Python.
try this:
pip install mysqlclient-1.4.4-cp38-cp38-win_amd64.whl
if it did’nt work, then use the 32bit version
pip install mysqlclient-1.4.4-cp38-cp38-win32.whl
The best way to install mysql-client is to go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient and you will find many mysql-client wheels.
- Download the first one #do not change the name of the file,,
- open command prompt,
- use cd to go to the directory where your wheel has been installed,
- then use pip install (name of file) #use .whl as well
if it doesn’t work, download the second one and repeat the process, if that doesn’t work as well, keep on downloading until I guarantee you that at least one of them would be installed in your computer
You can use pymysql
1.Install pymysql
pip install pymysql
-
Modify your init.py file
import pymysql
pymysql.install_as_MySQLdb()
You can start your project
Hi I am trying to install Mysqlclient
in Django and I got this message
collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Complete output from command 'c:usersusermo~1virtua~1tmsv2_~2scriptspython.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\userMO~1\AppData\Local\Temp\pip-install-vzfx29bg\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:UsersuserMO~1AppDataLocalTemppip-wheel-rd_6y67h' --python-tag cp37:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating buildlib.win32-3.7
creating buildlib.win32-3.7MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.7MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcompat.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.7MySQLdb
creating buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.7MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
creating buildtemp.win32-3.7
creating buildtemp.win32-3.7Release
creating buildtemp.win32-3.7ReleaseMySQLdb
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:Program Files (x86)MySQLMySQL Connector C 6.1includemariadb" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.7ReleaseMySQLdb/_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\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: 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
ERROR: Complete output from command 'c:usersusermo~1virtua~1tmsv2_~2scriptspython.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\userMO~1\AppData\Local\Temp\pip-install-vzfx29bg\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersuserMO~1AppDataLocalTemppip-record-ea_7lykdinstall-record.txt' --single-version-externally-managed --compile --install-headers 'c:usersusermo~1virtua~1tmsv2_~2includesitepython3.7mysqlclient':
ERROR: running install
running build
running build_py
creating build
creating buildlib.win32-3.7
creating buildlib.win32-3.7MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.7MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcompat.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.7MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.7MySQLdb
creating buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.7MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.7MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
creating buildtemp.win32-3.7
creating buildtemp.win32-3.7Release
creating buildtemp.win32-3.7ReleaseMySQLdb
C:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023binHostX86x86cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 "-IC:Program Files
(x86)MySQLMySQL Connector C 6.1includemariadb" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-Ic:usersuser moeappdatalocalprogramspythonpython37-32include" "-IC:Program Files (x86)Microsoft Visual Studio2017BuildToolsVCToolsMSVC14.16.27023include" "-IC:Program Files (x86)Windows KitsNETFXSDK4.6.1includeum" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0ucrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0shared" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0um" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0winrt" "-IC:Program Files (x86)Windows Kits10include10.0.17763.0cppwinrt" /TcMySQLdb/_mysql.c /Fobuildtemp.win32-3.7ReleaseMySQLdb/_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\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command "'c:usersusermo~1virtua~1tmsv2_~2scriptspython.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\Users\userMO~1\AppData\Local\Temp\pip-install-vzfx29bg\mysqlclient\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersuserMO~1AppDataLocalTemppip-record-ea_7lykdinstall-record.txt' --single-version-externally-managed --compile --install-headers 'c:usersusermo~1virtua~1tmsv2_~2includesitepython3.7mysqlclient'" failed with error code 1 in C:UsersuserMO~1AppDataLocalTemppip-install-vzfx29bgmysqlclient
I already tried several way
pip install opencv-contrib-python
(can install no work)pip install mysqlclient==1.3.12
(show same error)- I install the mycsqlclient from Wheel Link (show this error
mysqlclient-1.4.2-cp38-cp38m-win_amd64.whl is not a supported wheel on this platform.
)
My python version is: 3.7.3
(I come from desktop environment and while I read the Django, its say “Ridiculously fast” but now for MySQL connection problem took 4 days already).
I got the same error when I try to install mysqlclient in windows. after much time spent in this error. I found a result in the result install the latest visual studio and visual studio build tools. if programmer and only work on coding then transfer windows to ubuntu.i transfer on Ubuntu and enjoy coding
It seems like your Build Tools cannot handle some .h
files. You can use unofficial precompiled package database to get already compiled mysqlclient
.
After downloading it run
pip install name-of-whl-file.whl
If the python+win version of whl file fails to install, try using another version. Always works for me if Build Tools fail.
You have downloaded the wrong wheel. The error message says you tried to install mysqlclient-1.4.2-cp38-cp38m-win_amd64.whl
, which is for Python 3.8.
Since you are using Python 3.7, you should use either mysqlclient‑1.4.2‑cp37‑cp37m‑win32.whl
or mysqlclient‑1.4.2‑cp37‑cp37m‑win_amd64.whl
depending on whether you have installed 32-bit or 64-bit Python.
try this:
pip install mysqlclient-1.4.4-cp38-cp38-win_amd64.whl
if it did’nt work, then use the 32bit version
pip install mysqlclient-1.4.4-cp38-cp38-win32.whl
The best way to install mysql-client is to go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient and you will find many mysql-client wheels.
- Download the first one #do not change the name of the file,,
- open command prompt,
- use cd to go to the directory where your wheel has been installed,
- then use pip install (name of file) #use .whl as well
if it doesn’t work, download the second one and repeat the process, if that doesn’t work as well, keep on downloading until I guarantee you that at least one of them would be installed in your computer
You can use pymysql
1.Install pymysql
pip install pymysql
-
Modify your init.py file
import pymysql
pymysql.install_as_MySQLdb()
You can start your project