3

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!

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
Modern_Mo
  • 97
  • 8
  • "pip install mysqlclient NOTE: Wheels for Windows may be not released with source package. You should pin version in your requirements.txt to avoid trying to install newest source package." https://pypi.org/project/mysqlclient/ – Lingchao Cao Aug 28 '18 at 04:38

3 Answers3

1

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') 
piet.t
  • 11,718
  • 21
  • 43
  • 52
Youssri Abo Elseod
  • 671
  • 1
  • 9
  • 23
1

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

Sergio RBJ
  • 43
  • 2
  • 8
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
Rob
  • 415
  • 4
  • 12