I'm trying to install mysqlclient package in order to run my scripts over mySQL databases but I'm getting frutred since I already tried multiple options (PyMySQL, etc.) and none of those worked for me.
I'm trying to install using Pycharm import libraries and I am getting the following log error:
Collecting mysqlclient
creating build\lib.win32-3.7\MySQLdb
-ID:\Users\user\PycharmProjects\data_science\venv\include -ID:\Users\user\AppData\Local\Programs\Python\Python37-32\include -ID:\Users\user\AppData\Local\Programs\Python\Python37-32\include "-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\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /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: Cannot open include file: 'mysql.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
Which others possibilities that I have? Make a downgrade of Python to 2.7?
On my code I use the following imports:
import mysql.connector
from sqlalchemy import create_engine
Thanks for that
Not a direct solution, but why don't you use mysql.connector
, which is fully supported by python3
and recommend by mysql
?
Install:
pip install mysql-connector-python
Connect:
import mysql.connector
cnx = mysql.connector.connect(user='scott', password='password', host='127.0.0.1', database='employees')
cnx.close()
References:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.