Python MySQLdb “error: Microsoft Visual C++ 14.0 is required” even though it has been installed

吃可爱长大的小学妹 提交于 2020-01-14 10:46:05

问题


I'm attempting to connect to a MySql database and use its data for some code, though when I'm using

pip install mysqlclient

it gives me an error stating:

"error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools"

This link provided does not work, though i found out the correct link and installed the build tools as well as the "Windows 10 SDK" as other posts have specified. I sadly still am getting this error.

Anyone know what is wrong? Thanks!


回答1:


I believe if you need MySQL database, this is installed by other means i.e. see Microsoft webpage for details (https://dev.mysql.com/doc/refman/8.0/en/windows-installation.html).

If you just want to connect to MySQL database from Python, try installing mysql-connector instead.

pip install mysql-connector



回答2:


It's a complicated environment.

I suggest to use pyodbc to connect to your database ( it isn't required by c++ compiler installation)

Try to convert the below code in your program

import pyodbc

conn = pyodbc.connect('DRIVER={MySQL};SOCKET=/var/lib/mysql/mysql.sock;UID=rooter;PWD=sshh') 



回答3:


Try this:

1- Download mysqlclient wheel on Unoffical Windows Binaries for Python Extension Packages. (search for mysqlclient-1.3.13-cp37-cp37m-win32)

2- Install manually pip install mysqlclient-1.3.13-cp37-cp37m-win32.whl



来源:https://stackoverflow.com/questions/52050023/python-mysqldb-error-microsoft-visual-c-14-0-is-required-even-though-it-has

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!