下载mysqlclient报错

下载mysqlclient报错

ERROR: Command errored out with exit status 1:
     command: 'd:\python\python.exe' -u -c 'import sys, setuptools,
 tokenize; sys.argv[0] = '"'"'C:\\Users\\52646\\AppData\\Local\\Tem
p\\pip-install-7x2tdbba\\mysqlclient\\setup.py'"'"'; __file__='"'"'
C:\\Users\\52646\\AppData\\Local\\Temp\\pip-install-7x2tdbba\\mysql
client\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__f
ile__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close(
);exec(compile(code, __file__, '"'"'exec'"'"'))' install --record '
C:\Users\52646\AppData\Local\Temp\pip-record-6ow589js\install-recor
d.txt' --single-version-externally-managed --compile
         cwd: C:\Users\52646\AppData\Local\Temp\pip-install-7x2tdbb
a\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\My
SQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQ
Ldb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\
constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\
constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\
MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLd
b\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\V
C\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3
/GL /DNDEBUG /MT -Dversion_info=(1,4,4,'final',0) -D__version__=1.4
.4 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\ma
riadb" -Id:\python\include -Id:\python\include "-IC:\Program Files
(x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28
105\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Stud
io\2019\Community\VC\Tools\MSVC\14.23.28105\include" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Pr
ogram Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Pr
ogram Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:
\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt"
 /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql
.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “my
sql.h”: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studi
o\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86
\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\python\python.ex
e' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\
Users\\52646\\AppData\\Local\\Temp\\pip-install-7x2tdbba\\mysqlclie
nt\\setup.py'"'"'; __file__='"'"'C:\\Users\\52646\\AppData\\Local\\
Temp\\pip-install-7x2tdbba\\mysqlclient\\setup.py'"'"';f=getattr(to
kenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'
"'exec'"'"'))' install --record 'C:\Users\52646\AppData\Local\Temp\
pip-record-6ow589js\install-record.txt' --single-version-externally
-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 19.3.1 i
s available.
You should consider upgrading via the 'python -m pip install --upgr
ade pip' command.

C:\Users\52646\Desktop\learn_flask>pip3 install mysqlclient -i http
s://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting mysqlclient
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4d/38/c5f
8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclie
nt-1.4.4.tar.gz
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\python\python.exe' -u -c 'import sys, setuptools,
 tokenize; sys.argv[0] = '"'"'C:\\Users\\52646\\AppData\\Local\\Tem
p\\pip-install-0472yvvd\\mysqlclient\\setup.py'"'"'; __file__='"'"'
C:\\Users\\52646\\AppData\\Local\\Temp\\pip-install-0472yvvd\\mysql
client\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__f
ile__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close(
);exec(compile(code, __file__, '"'"'exec'"'"'))' install --record '
C:\Users\52646\AppData\Local\Temp\pip-record-sz5nd20p\install-recor
d.txt' --single-version-externally-managed --compile
         cwd: C:\Users\52646\AppData\Local\Temp\pip-install-0472yvv
d\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\My
SQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQ
Ldb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\
constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\
constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\
MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLd
b\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\V
C\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3
/GL /DNDEBUG /MT -Dversion_info=(1,4,4,'final',0) -D__version__=1.4
.4 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\ma
riadb" -Id:\python\include -Id:\python\include "-IC:\Program Files
(x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28
105\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Stud
io\2019\Community\VC\Tools\MSVC\14.23.28105\include" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Pr
ogram Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Pr
ogram Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:
\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt"
 /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql
.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “my
sql.h”: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studi
o\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86
\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\python\python.ex
e' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\
Users\\52646\\AppData\\Local\\Temp\\pip-install-0472yvvd\\mysqlclie
nt\\setup.py'"'"'; __file__='"'"'C:\\Users\\52646\\AppData\\Local\\
Temp\\pip-install-0472yvvd\\mysqlclient\\setup.py'"'"';f=getattr(to
kenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'
"'exec'"'"'))' install --record 'C:\Users\52646\AppData\Local\Temp\
pip-record-sz5nd20p\install-record.txt' --single-version-externally
-managed --compile Check the logs for full command output.

C:\Users\52646\Desktop\learn_flask>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v
.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more informati
on.
>>> from app import db
D:\Python\lib\site-packages\flask_sqlalchemy\__init__.py:835: FSADe
precationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant o
verhead and will be disabled by default in the future.  Set it to T
rue or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
>>> db.create_all()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python\lib\site-packages\flask_sqlalchemy\__init__.py",
line 1033, in create_all
    self._execute_for_all_tables(app, bind, 'create_all')
  File "D:\Python\lib\site-packages\flask_sqlalchemy\__init__.py",
line 1025, in _execute_for_all_tables
    op(bind=self.get_engine(app, bind), **extra)
  File "D:\Python\lib\site-packages\flask_sqlalchemy\__init__.py",
line 956, in get_engine
    return connector.get_engine()
  File "D:\Python\lib\site-packages\flask_sqlalchemy\__init__.py",
line 561, in get_engine
    self._engine = rv = self._sa.create_engine(sa_url, options)
  File "D:\Python\lib\site-packages\flask_sqlalchemy\__init__.py",
line 966, in create_engine
    return sqlalchemy.create_engine(sa_url, **engine_opts)
  File "D:\Python\lib\site-packages\sqlalchemy\engine\__init__.py",
 line 479, in create_engine
    return strategy.create(*args, **kwargs)
  File "D:\Python\lib\site-packages\sqlalchemy\engine\strategies.py
", line 87, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "D:\Python\lib\site-packages\sqlalchemy\dialects\mysql\mysql
db.py", line 118, in dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
>>> import pymysql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pymysql'
>>> exit()

C:\Users\52646\Desktop\learn_flask>pip install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/4d/38/c5f8ba
c9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-
1.4.4.tar.gz
Installing collected packages: mysqlclient
    Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\python\python.exe' -u -c 'import sys, setuptools,
 tokenize; sys.argv[0] = '"'"'C:\\Users\\52646\\AppData\\Local\\Tem
p\\pip-install-tatd8glp\\mysqlclient\\setup.py'"'"'; __file__='"'"'
C:\\Users\\52646\\AppData\\Local\\Temp\\pip-install-tatd8glp\\mysql
client\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__f
ile__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close(
);exec(compile(code, __file__, '"'"'exec'"'"'))' install --record '
C:\Users\52646\AppData\Local\Temp\pip-record-78y50xqt\install-recor
d.txt' --single-version-externally-managed --compile
         cwd: C:\Users\52646\AppData\Local\Temp\pip-install-tatd8gl
p\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\My
SQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQ
Ldb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\
constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\
constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\
MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLd
b\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\V
C\Tools\MSVC\14.23.28105\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3
/GL /DNDEBUG /MT -Dversion_info=(1,4,4,'final',0) -D__version__=1.4
.4 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\ma
riadb" -Id:\python\include -Id:\python\include "-IC:\Program Files
(x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28
105\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Stud
io\2019\Community\VC\Tools\MSVC\14.23.28105\include" "-IC:\Program
Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Progra
m Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Pr
ogram Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Pr
ogram Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:
\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt"
 /TcMySQLdb/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql
.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “my
sql.h”: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studi
o\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86
\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\python\python.ex
e' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\
Users\\52646\\AppData\\Local\\Temp\\pip-install-tatd8glp\\mysqlclie
nt\\setup.py'"'"'; __file__='"'"'C:\\Users\\52646\\AppData\\Local\\
Temp\\pip-install-tatd8glp\\mysqlclient\\setup.py'"'"';f=getattr(to
kenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'
"'exec'"'"'))' install --record 'C:\Users\52646\AppData\Local\Temp\
pip-record-78y50xqt\install-record.txt' --single-version-externally
-managed --compile Check the logs for full command output.


正在回答

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

1回答

同学,你好。

使用pip命令安装mysqlclient大多数情况下是会报错的。同学可以在https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python 该页面中选择相对应的版本进行下载。在终端中进到所对应的环境中和文件所在的路径中安装就可以了。

http://img1.sycdn.imooc.com//climg/5dbe7b1c09144d0005850272.jpg

http://img1.sycdn.imooc.com//climg/5dbe7b2309b4847a05990208.jpg

如果我的回答解决了您的疑惑,请采纳!祝学习愉快~~~~

  • JiaXionG_Lynn 提问者 #1
    试过了还是报错
    2019-11-03 15:03:09
问题已解决,确定采纳
还有疑问,暂不采纳

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

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

0 星
3.从网页搭建入门Python Web
  • 参与学习           人
  • 提交作业       218    份
  • 解答问题       3562    个

本阶段带你用Python开发一个网站,学习主流框架Django+Flask是Python Web开发的第一步,在基础知识上实现积分商城的项目开发,体验真实的项目开发流程,提高解决编程问题和效率的能力。

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

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