Windows环境下Pycharm安装Redis数据库,及安装mysqlclient包遇到的问题

Windows环境下Pycharm安装Redis数据库,及安装mysqlclient包遇到的问题

起因

因需要本人在本地跑一个之前做的一个Python项目,在搭建环境的时候用到 Redis数据库,需要下载redis包及扩展,采用pip install 方式,发现老是不成功,经过查阅资料各种尝试后终于成功,也算是自己的一篇记录,希望能给大家带来帮助

环境

Pycharm + Python3.6 + MySQL5.5 + Redis3.0.504

Redis

Redis下载地址:https://github.com/microsoftarchive/redis/releases

所报错误第一次

 ERROR: Command errored out with exit status 1:
  command: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:
\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-mc0v3g62\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI~1
\\AppData\\Local\\Temp\\pip-install-mc0v3g62\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__)
;code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d
 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-wheel-hbqo99q6' --python-tag cp36
       cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-mc0v3g62\mysqlclient\
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\compat.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
  creating build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  running build_ext
  building '_mysql' extension
  error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microso
ft.com/downloads/
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
  Building wheel for python-editor (setup.py) ... done
  Created wheel for python-editor: filename=python_editor-1.0.3-cp36-none-any.whl size=6693 sha256=014d62cf46cca032c7d07b410
4e758c58debad95a54530532f91e291f9996ead
  Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\36\e0\98\ba386b125a00ea9dd52e2c16aa2ec0adbbd639
b84bfe2e001d
  Building wheel for qiniu (setup.py) ... done
  Created wheel for qiniu: filename=qiniu-7.2.2-cp36-none-any.whl size=29754 sha256=3714ee1509b1c88112ccb20ce9b6082190043409
05bf91e3af0177881bc39038
  Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\29\09\24\3a4b1c5e0e7a6ce05105b54cb458075f07c1a9
4f40de9db906
  Building wheel for SQLAlchemy (setup.py) ... done
  Created wheel for SQLAlchemy: filename=SQLAlchemy-1.2.13-cp36-cp36m-win_amd64.whl size=1098193 sha256=d24d24eae2307ed0446b
414165377fa8de5642ce218a13099da956b733b88c9a
  Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\ba\2e\47\b194b03e6aeaa658f521dfba094a42f1d37f4e
e4018b9e607e
Successfully built alembic backcall blinker Flask Flask-MySQLdb Flask-Script Mako MarkupSafe python-editor qiniu SQLAlchemy
Failed to build mysqlclient
Installing collected packages: SQLAlchemy, MarkupSafe, Mako, python-editor, six, python-dateutil, alembic, backcall, blinker
, certifi, chardet, decorator, Werkzeug, Jinja2, itsdangerous, Flask, Flask-SQLAlchemy, Flask-Migrate, mysqlclient, Flask-My
SQLdb, Flask-Script, Flask-Session, WTForms, Flask-WTF, idna, Pygments, colorama, parso, jedi, pickleshare, wcwidth, prompt-
toolkit, ipython-genutils, traitlets, ipython, ptyprocess, pexpect, Pillow, urllib3, requests, qiniu, redis
  Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'
C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-mc0v3g62\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI
~1\\AppData\\Local\\Temp\\pip-install-mc0v3g62\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file_
_);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --re
cord 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-akcrheau\install-record.txt' --single-version-externally-managed --com
pile --install-headers 'c:\users\administrator\flask\include\site\python3.6\mysqlclient'
         cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-mc0v3g62\mysqlclient\
    Complete output (25 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
    creating build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.micro
soft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptoo
ls, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-mc0v3g62\\mysqlclient\\setup.py'"'"'
; __file__='"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-mc0v3g62\\mysqlclient\\setup.py'"'"';f=getattr(tokeni
ze, '"'"'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\pip-record-akcrheau\install-record.txt' --single
-version-externally-managed --compile --install-headers 'c:\users\administrator\flask\include\site\python3.6\mysqlclient' Ch
eck the logs for full command output.

问题
1、error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microso ft.com/downloads/
原因:咱也不知道,但是咱敢问(在网上找的解释)
/因为很多时候即使我们安装成功了它说的对应的运行库,还是不行,必须安装所有的运行库才可以,不知道它还需要什么库
解决办法:根据报错信息去官网下载 Microsoft Visual C++ 14.0,或者看第2步,下载whl库到本地

2、ERROR: Failed building wheel for mysqlclient
原因:缺失相应的whl文件/库。
解决办法:下载并安装对应的whl库(下见whl库网址)
whl库网址

所报错误第二次

(根据第一步操作后)
ERROR: Command errored out with exit status 1:
     command: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'
C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-avguiasy\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI
~1\\AppData\\Local\\Temp\\pip-install-avguiasy\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file_
_);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --re
cord 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-6yilhufq\install-record.txt' --single-version-externally-managed --com
pile --install-headers 'c:\users\administrator\flask\include\site\python3.6\mysqlclient'
         cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-avguiasy\mysqlclient\
    Complete output (30 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
    creating build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversio
n_info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\users\adm
inistrator\appdata\local\programs\python\python36\include -Ic:\users\administrator\appdata\local\programs\python\python36\in
clude "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\1
0.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\incl
ude\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj
 /Zl
    _mysql.c
    _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\\x86_amd64\\cl.exe' failed with exit stat
us 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptoo
ls, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-avguiasy\\mysqlclient\\setup.py'"'"'
; __file__='"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-avguiasy\\mysqlclient\\setup.py'"'"';f=getattr(tokeni
ze, '"'"'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\pip-record-6yilhufq\install-record.txt' --single
-version-externally-managed --compile --install-headers 'c:\users\administrator\flask\include\site\python3.6\mysqlclient' Ch
eck the logs for full command output.

1、error:_mysql.c _mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
原因:因为使用的是集成包MySQL数据库的原因,缺少mysql.h文件,所以报错
解决方法:下载MySQL源文件 密码:e9fa,
这是需要复制的文件
将文件手动复制到某文件夹进去(这个文件夹指的是pip install python包时寻找的目录,大家耐心一点可以发现这样的目录,I开头的就ok)
error错误信息,文件目录
复制成功后
在这里插入图片描述

所报错误第三次

 ERROR: Command errored out with exit status 1:
   command: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:
\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-nj4ocxl0\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI~1
\\AppData\\Local\\Temp\\pip-install-nj4ocxl0\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__)
;code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d
 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-wheel-0joz1w0w' --python-tag cp36
       cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-nj4ocxl0\mysqlclient\
  Complete output (62 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\compat.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
  copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
  creating build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
  running build_ext
  building '_mysql' extension
  creating build\temp.win-amd64-3.6
  creating build\temp.win-amd64-3.6\Release
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_
info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\users\admin
istrator\appdata\local\programs\python\python36\include -Ic:\users\administrator\appdata\local\programs\python\python36\incl
ude "-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\includ
e\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /
Zl
  _mysql.c
  _mysql.c(247): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(277): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(418): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(753): warning C4244: 'function': conversion from 'SOCKET' to 'long', possible loss of data
  _mysql.c(1087): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(1192): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
  _mysql.c(1404): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1406): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1403): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
  _mysql.c(1405): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
  _mysql.c(1407): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
  _mysql.c(1442): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1444): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  _mysql.c(1441): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
  _mysql.c(1443): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
  _mysql.c(1446): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
  _mysql.c(2152): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long'
  _mysql.c(2155): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long'
  _mysql.c(2150): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
  _mysql.c(2154): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
  _mysql.c(2189): warning C4311: 'type cast': pointer truncation from '_mysql_ResultObject *' to 'long'
  _mysql.c(2189): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To di
sable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST
:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib\vs14" /LIBPATH:c:\users\adminis
trator\appdata\local\programs\python\python36\Libs /LIBPATH:c:\users\administrator\flask\libs /LIBPATH:c:\users\administrato
r\flask\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files
 (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" kern
el32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:PyInit__mysql build\temp.win-amd64-3.6\Release\_mysql.obj /OUT:bui
ld\lib.win-amd64-3.6\_mysql.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.lib /MANIFEST
  LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit stat
us 1181
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient, Flask-MySQLdb, Flask-Script, Flask-Session, WTForms, Flask-WTF, idna, wcwidth, p
rompt-toolkit, ipython-genutils, traitlets, parso, jedi, Pygments, colorama, pickleshare, ipython, ptyprocess, pexpect, Pill
ow, urllib3, requests, qiniu, redis
  Found existing installation: mysqlclient 1.4.4
    Uninstalling mysqlclient-1.4.4:
      Successfully uninstalled mysqlclient-1.4.4
  Running setup.py install for mysqlclient ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'
C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-nj4ocxl0\\mysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI
~1\\AppData\\Local\\Temp\\pip-install-nj4ocxl0\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file_
_);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --re
cord 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-o9317uz5\install-record.txt' --single-version-externally-managed --com
pile --install-headers 'c:\users\administrator\flask\include\site\python3.6\mysqlclient'
         cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-nj4ocxl0\mysqlclient\
    Complete output (62 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
    creating build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversio
n_info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\users\adm
inistrator\appdata\local\programs\python\python36\include -Ic:\users\administrator\appdata\local\programs\python\python36\in
clude "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\1
0.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\incl
ude\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj
 /Zl
    _mysql.c
    _mysql.c(247): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(277): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(418): warning C4244: 'initializing': conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(753): warning C4244: 'function': conversion from 'SOCKET' to 'long', possible loss of data
    _mysql.c(1087): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(1192): warning C4244: '=': conversion from 'Py_ssize_t' to 'int', possible loss of data
    _mysql.c(1404): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1406): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1403): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
    _mysql.c(1405): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
    _mysql.c(1407): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
    _mysql.c(1442): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1444): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
    _mysql.c(1441): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(346): note: see declaration of 'strncpy'
    _mysql.c(1443): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
    _mysql.c(1446): warning C4996: 'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\string.h(255): note: see declaration of 'strncat'
    _mysql.c(2152): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long'
    _mysql.c(2155): warning C4311: 'type cast': pointer truncation from '_mysql_ConnectionObject *' to 'long'
    _mysql.c(2150): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
    _mysql.c(2154): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
    _mysql.c(2189): warning C4311: 'type cast': pointer truncation from '_mysql_ResultObject *' to 'long'
    _mysql.c(2189): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To
disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1769): note: see declaration of 'sprintf'
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFE
ST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib\vs14" /LIBPATH:c:\users\admin
istrator\appdata\local\programs\python\python36\Libs /LIBPATH:c:\users\administrator\flask\libs /LIBPATH:c:\users\administra
tor\flask\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Fil
es (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" ke
rnel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:PyInit__mysql build\temp.win-amd64-3.6\Release\_mysql.obj /OUT:b
uild\lib.win-amd64-3.6\_mysql.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\_mysql.cp36-win_amd64.lib /MANIFES
T
    LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit st
atus 1181
    ----------------------------------------
  Rolling back uninstall of mysqlclient
  Moving to c:\users\administrator\flask\lib\site-packages\mysqlclient-1.4.4.dist-info\
   from c:\users\administrator\flask\lib\site-packages\~ysqlclient-1.4.4.dist-info
  Moving to c:\users\administrator\flask\lib\site-packages\mysqldb\
   from c:\users\administrator\flask\lib\site-packages\~ysqldb
ERROR: Command errored out with exit status 1: 'c:\users\administrator\flask\scripts\python.exe' -u -c 'import sys, setuptoo
ls, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-nj4ocxl0\\mysqlclient\\setup.py'"'"'
; __file__='"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-nj4ocxl0\\mysqlclient\\setup.py'"'"';f=getattr(tokeni
ze, '"'"'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\pip-record-o9317uz5\install-record.txt' --single
-version-externally-managed --compile --install-headers 'c:\users\administrator\flask\include\site\python3.6\mysqlclient' Ch
eck the logs for full command output.

问题LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
原因:不能打开mysqlclient.lib文件
解决:复制MySQL-server包中,lib目录下的mysqlclient.lib
在这里插入图片描述
复制到报错信息中任意**/LIBPATH**中
在这里插入图片描述
在这里插入图片描述

感言

大功告成,pip install mysqlclient 正常安装完成,其实只要是下载与电脑上系统版本与Python版本相符合的whl库就ok了,也是折腾了这么久,不过还不错,也是一处经验吧,有问题的话可以留言进行讨论,一起学习,共同进步!
测试Redis是否正常使用
import redis


if __name__=="__main__":
    r = redis.Redis(host="localhost", port=6379, decode_responses=True)
    r.set("name", "a")
    print(r.get("name"))
   #运行成功且打印“a”则正常使用
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值