简体   繁体   English

Pycharm - Python 3.7 - 无法安装 mySQLclient

[英]Pycharm - Python 3.7 - Cannot install mySQLclient

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.我正在尝试安装 mysqlclient package 以便在 mySQL 数据库上运行我的脚本,但我感到很沮丧,因为我已经尝试了多个选项(PyMySQL 等),但没有一个对我有用。

I'm trying to install using Pycharm import libraries and I am getting the following log error:我正在尝试使用 Pycharm 导入库进行安装,但出现以下日志错误:

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?将 Python 降级到 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 ?不是直接的解决方案,但你为什么不使用mysql.connector ,它由python3完全支持并由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:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM