django安装mysqlclient (Windows下正确安装mysqlclient)

django安装mysqlclient (Windows下正确安装mysqlclient)由于本人也是初学 Python 和 django 本人使用的 Python 版本是 3 7 所以连接 MySQL 数据库需要安装数据驱动 对应 Python3 的数据驱动是 mysqlclient 因此本人习惯性的使用命令 pipinstallmy 结果安装失败 venv C Users songlihui PycharmProje autotest gt pipinstallmy

由于本人也是初学Python和django。本人使用的Python版本是3.7所以连接MySQL数据库需要安装数据驱动,对应Python3的数据驱动是mysqlclient。因此本人习惯性的使用命令pip install mysqlclient,结果安装失败

(venv) C:\Users\songlihui\PycharmProjects\autotest>pip install mysqlclient Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9edbb1988ad/mysqlclient-1.3.13.tar.gz Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command C:\Users\songlihui\PycharmProjects\autotest\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SONGLI~1\\AppData\\Local\ \Temp\\pip-install-1yliga_x\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" i nstall --record C:\Users\SONGLI~1\AppData\Local\Temp\pip-record-d20e0g2u\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\songlihui\Pycharm Projects\autotest\venv\include\site\python3.7\mysqlclient: C:\Users\songlihui\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running install running build running build_py creating build creating build\lib.win32-3.7 copying _mysql_exceptions.py -> build\lib.win32-3.7 creating build\lib.win32-3.7\MySQLdb copying MySQLdb\__init__.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\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\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\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants running build_ext building '_mysql' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools ---------------------------------------- Command "C:\Users\songlihui\PycharmProjects\autotest\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SONGLI~1\\AppData\\Local\\Temp\\pip-install-1ylig a_x\\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 \SONGLI~1\AppData\Local\Temp\pip-record-d20e0g2u\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\songlihui\PycharmProjects\autotest\venv\i nclude\site\python3.7\mysqlclient" failed with error code 1 in C:\Users\SONGLI~1\AppData\Local\Temp\pip-install-1yliga_x\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.

然后就从网上寻找各种安装的文章,然后发现一篇文章说

到这个地址下载自己版本对应的资源到本地,然后进行安装 https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient 

django安装mysqlclient (Windows下正确安装mysqlclient)

然后我进入下载的资源所在目录

django安装mysqlclient (Windows下正确安装mysqlclient)

然后使用命令安装,结果仍然失败

django安装mysqlclient (Windows下正确安装mysqlclient)

然后又苦苦的寻找各种解决办法和答案,幸运的是又让我找到一篇文章是这么说的

下载32位的版本安装能成功,因此我有继续下载如下图中的版本

django安装mysqlclient (Windows下正确安装mysqlclient)

然后继续执行安装的命令,出人意料,竟然成了!至于原因,因为我的Python版本是32。因此分享给大家,大家有问题欢迎留言评论~

django安装mysqlclient (Windows下正确安装mysqlclient)

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233359.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号