老师,请教下Windows平台安装mysqlclient扩展的时候出现如下问题

来源:4-8 数据库ORM

慕前端8517143

2018-09-04

E:\mooc>pip install mysqlclient

Collecting mysqlclient

  Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c

5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz

Installing collected packages: mysqlclient

  Running setup.py install for mysqlclient ... error

    Complete output from command E:\python_Pycharm\python3\python.exe -u -c "import setuptools, t

okenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-z2d5aadd\\mysqlclient\\s

etup.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\ADMINI~1\AppData\Local\Temp\pi

p-record-21dm6sja\install-record.txt --single-version-externally-managed --compile:

    E:\python_Pycharm\python3\lib\distutils\dist.py:261: UserWarning: Unknown distribution option

: 'long_description_content_type'

      warnings.warn(msg)

    running install

    running build

    running build_py

    creating build

    creating build\lib.win-amd64-3.5

    copying _mysql_exceptions.py -> build\lib.win-amd64-3.5

    creating build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\__init__.py -> build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\compat.py -> build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\connections.py -> build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\converters.py -> build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\cursors.py -> build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\release.py -> build\lib.win-amd64-3.5\MySQLdb

    copying MySQLdb\times.py -> build\lib.win-amd64-3.5\MySQLdb

    creating build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.5\MySQLdb\constants

    running build_ext

    building '_mysql' extension

    error: [WinError 2] 系统找不到指定的文件。


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

Command "E:\python_Pycharm\python3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Us

ers\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-z2d5aadd\\mysqlclient\\setup.py';f=getattr(token

ize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __f

ile__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-21dm6sja\instal

l-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\

ADMINI~1\AppData\Local\Temp\pip-install-z2d5aadd\mysqlclient\

You are using pip version 10.0.1, however version 18.0 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.


写回答

2回答

慕前端8517143

提问者

2018-09-04

成功解决了。执行pip install mysqlclient无法安装时候,可以采取本地安装,先从:https://www.lfd.uci.edu/~gohlke/pythonlibs/#

下载:mysqlclient-1.3.13-cp35-cp35m-win_amd64.whl

然后PyCharm中执行进入mysqlclient-1.3.13-cp35-cp35m-win_amd64.whl的上级目录

在PyCharm中执行:pip install mysqlclient-1.3.13-cp35-cp35m-win_amd64.whl


1
3
慕桂英5446361
6666 看了网上好多方法解决不了 用你的方式一弄就好 大神 6666
2019-01-14
共3条回复

路人荚

2018-09-23

windows建议采用pymysql,然后在项目的init文件中添加

0
1
路人荚
import pymysql pymysql.install_as_MySQLdb()
2018-09-23
共1条回复

Python Flask构建微信小程序订餐系统(可用于毕设)

微信小程序 + Python Flask 打造订餐系统全栈应用,可用于毕设。

1709 学习 · 1904 问题

查看课程