pip版本是最新的,安装mysqlclient还是失败

pip版本是最新的,安装mysqlclient还是失败

老师您好,我的pip版本已经是最新的了,但是安装mysqlclient还是报错

错误信息:

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

Collecting mysqlclient==2.0.3

  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/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

  Attempting uninstall: mysqlclient

    Found existing installation: mysqlclient 1.4.6

    Uninstalling mysqlclient-1.4.6:

      Successfully uninstalled mysqlclient-1.4.6

    Running setup.py install for mysqlclient: started

    Running setup.py install for mysqlclient: finished with status 'error'

  Rolling back uninstall of mysqlclient

  Moving to d:\mooc\qa_flask\venv\lib\site-packages\mysqlclient-1.4.6.dist-info\

   from D:\mooc\qa_flask\venv\Lib\site-packages\~ysqlclient-1.4.6.dist-info

  Moving to d:\mooc\qa_flask\venv\lib\site-packages\mysqldb\

   from D:\mooc\qa_flask\venv\Lib\site-packages\~ysqldb


    ERROR: Command errored out with exit status 1:

     command: 'D:\mooc\qa_flask\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\Temp\\pip-install-txqqbh1n\\mysqlclient_1a1bf352722d4aa1bf6a651bf98afdcb\\setup.py'"'"'; __file__='"'"'D:\\Temp\\pip-install-txqqbh1n\\mysqlclient_1a1bf352722d4aa1bf6a651bf98afdcb\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'D:\Temp\pip-record-uztqbpa0\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\mooc\qa_flask\venv\include\site\python3.8\mysqlclient'

         cwd: D:\Temp\pip-install-txqqbh1n\mysqlclient_1a1bf352722d4aa1bf6a651bf98afdcb\

    Complete output (31 lines):

    running install

    running build

    running build_py

    creating build

    creating build\lib.win32-3.8

    creating build\lib.win32-3.8\MySQLdb

    copying MySQLdb\__init__.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\_exceptions.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\connections.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\converters.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\cursors.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\release.py -> build\lib.win32-3.8\MySQLdb

    copying MySQLdb\times.py -> build\lib.win32-3.8\MySQLdb

    creating build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\CR.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\ER.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.8\MySQLdb\constants

    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.8\MySQLdb\constants

    warning: build_py: byte-compiling is disabled, skipping.

    

    running build_ext

    building 'MySQLdb._mysql' extension

    creating build\temp.win32-3.8

    creating build\temp.win32-3.8\Release

    creating build\temp.win32-3.8\Release\MySQLdb

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\mariadb" -ID:\mooc\qa_flask\venv\include -IC:\Users\娴f洖銇塡AppData\Local\Programs\Python\Python38-32\include -IC:\Users\娴f洖銇塡AppData\Local\Programs\Python\Python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.8\Release\MySQLdb/_mysql.obj

    _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 14.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------

ERROR: Command errored out with exit status 1: 'D:\mooc\qa_flask\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'D:\\Temp\\pip-install-txqqbh1n\\mysqlclient_1a1bf352722d4aa1bf6a651bf98afdcb\\setup.py'"'"'; __file__='"'"'D:\\Temp\\pip-install-txqqbh1n\\mysqlclient_1a1bf352722d4aa1bf6a651bf98afdcb\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'D:\Temp\pip-record-uztqbpa0\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\mooc\qa_flask\venv\include\site\python3.8\mysqlclient' Check the logs for full command output.


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学,你好!安装失败可能与Python版本有关,可尝试以下安装方法:

1、先查看一下电脑中的Python版本,然后下载对应版本的mysqlclient,链接:https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

http://img1.sycdn.imooc.com//climg/606c31bd09514e1705930390.jpg

2、进入到下载目录,执行命令pip install mysqlclient-xxx.whl进行安装

祝:学习愉快!

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师