我目前正在学习一个Django教程,在尝试安装mysqlclient后,我的CMD上出现了以下错误消息。
提前非常感谢
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
Complete output from command c:usersoenvspy1scriptspython.exe -u
-c "import setuptools,
tokenize;__file__='C:\Users\O\AppData\Local\T
emp\pip-install-kej8gk5_\mysqlclient\setup.py';f=getattr(tokenize,
'open', op
en)(__file__);code=f.read().replace('rn',
'n');f.close();exec(compile(code, _
_file__, 'exec'))" install --record
C:UsersOAppDataLocalTemppip-reco
rd-_27hw8hlinstall-record.txt --single-version-externally-managed --
compile --install-headers
c:usersoenvspy1includesitepython3.7mysqlclient:
running install
running build
running build_py
creating build
creating buildlib.win32-3.7
copying _mysql_exceptions.py -> buildlib.win32-3.7
creating buildlib.win32-3.7MySQLdb
copying MySQLdb__init__.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
copying MySQLdbconstantsREFRESH.py -> buildlib.win32-3.7MySQLdbconstants
running build_ext
building '_mysql' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
我建议使用Python 64位。
当 mysql 是 64 位和 python 是 32 位时,当我们通过这个网站强制安装 mysqlclient 时,就会出现此问题Python扩展包 或者您可以同时安装32位pip install mysqlclient
或使用此:pip install --only-binary :all: mysqlclient
使用64位python,您可以轻松安装它。