今天在学习python连接mysql安装的时候,使用pip install mysqlclient,安装mysql客户端时报错,报错如下:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
Command "E:\WorkProject\python_work\py_first\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Administrator\\AppData\\Local\\Temp\\p
ip-install-ibp7i745\\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\Administrator\AppData\Local\Temp\pip-record-tymnqolj\install-record.txt --single-version-externally-managed --compile --install
-headers E:\WorkProject\python_work\py_first\venv\include\site\python3.8\mysqlclient" failed with error code 1 in C:\Users\Administrator\AppData\Local\Temp\pip-ins
tall-ibp7i745\mysqlclient\
最后的mysqlclient说明缺少该包,需要安装,安装方式如下:
插件访问地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/ ,在这里面搜索查找版本,下载mysqlclient-1.4.6-cp38-cp38-win_amd64.whl,放到python解析器安装目录的Scripts下,通过pip install mysqlclient-1.4.6-cp38-cp38-win_amd64.whl,进行安装。
在使用pip install mysqlclient-1.4.6-cp38-cp38-win_amd64.whl 如果报错:ERROR: mysqlclient-1.4.6-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.
需要用:python -c "import wheel.pep425tags as w;print(w.get_supported())",查看支持的版本:
[('cp38', 'cp38', 'win_amd64'), ('cp38', 'none', 'win_amd64'), ('cp38', 'none', 'any'), ('cp3', 'none', 'any'), ('cp37', 'none', 'any'), ('cp36', 'none', 'any'), ('cp35', 'none', 'any'), ('cp34', 'none', 'any'), ('cp33', 'none', 'any'), ('cp32', 'none', 'any'), ('cp31', 'none', 'any'), ('cp30', 'none', 'any'), ('py3', 'none', 'win_amd64'), ('py38', 'none', 'any'), ('py3', 'none', 'any'), ('py37','none', 'any'), ('py36','none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33','none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]
如果还报错:ModuleNotFoundError: No module named 'wheel'
安装wheel:easy_install wheel