在cmd提示符下使用命令安装mysql-connector
时:
pip3 install mysql-connector
显示安装成功,但出现此错误:
mysql-connector-python 8.0.15 requires protobuf>=3.0.0, which is not installed windows 8.1
我找不到可能需要的 protobuf
正确版本的安装说明。
稍后,在pycharm
中使用语句建立数据库连接时
mydb = mysql.connector.connect(host, user, passwd)
我收到此错误:
ModuleNotFoundError: No module named 'mysql'
知道如何继续吗?在 Windows 8.1 上使用 python 3.7
最佳答案
要使用 pip use 安装 protubuf
,
pip3 install protubuf
的版本为 3.6.1
。
对于 mysql ImportError
,包 ConfigParser
已在 Python 3 中重命名为 configparser
。
为此,在安装mysql
后再次使用pip安装configparser
pip3 install configparser
关于python - 在Windows中连接MySQL到Python时出现缺少protobuf的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54675687/