我无法安装mysqlclient


pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.0.3.tar.gz (88 kB)
Using legacy setup.py install for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: 'c:usersblackknightdesktopsimpleblogmyenvscriptspython.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Blackknight\AppData\Local\Temp\pip-install-85jgwelt\mysqlclient\setup.py'"'"'; __file__='"'"'C:\Users\Blackknight\AppData\Local\Temp\pip-install-85jgwelt\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:UsersBlackknightAppDataLocalTemppip-record-7y2zgqqainstall-record.txt' --single-version-externally-managed --compile --install-headers 'c:usersblackknightdesktopsimpleblogmyenvincludesitepython3.8mysqlclient'
cwd: C:UsersBlackknightAppDataLocalTemppip-install-85jgweltmysqlclient
Complete output (23 lines):
running install
running build
running build_py
creating build
creating buildlib.win32-3.8
creating buildlib.win32-3.8MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-3.8MySQLdb
copying MySQLdb_exceptions.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-3.8MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-3.8MySQLdb
creating buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-3.8MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-3.8MySQLdbconstants
running build_ext
building 'MySQLdb._mysql' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ 
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:usersblackknightdesktopsimpleblogmyenvscriptspython.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Blackknight\AppData\Local\Temp\pip-install-85jgwelt\mysqlclient\setup.py'"'"'; __file__='"'"'C:\Users\Blackknight\AppData\Local\Temp\pip-install-85jgwelt\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:UsersBlackknightAppDataLocalTemppip-record-7y2zgqqainstall-record.txt' --single-version-externally-managed --compile --install-headers 'c:usersblackknightdesktopsimpleblogmyenvincludesitepython3.8mysqlclient' Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.
You should consider upgrading via the 'c:usersblackknightdesktopsimpleblogmyenvscriptspython.exe -m pip install --upgrade pip' command.

您需要安装visual c++构建工具。你可以在这里下载。然后再次尝试安装mysqlclient

第二个选项您也可以通过进行二进制安装

pip install --only-binary :all: mysqlclient

可选最好升级你的pip运行pip install --upgrade pip

最新更新