解决wrap_socket() got an unexpected keyword argument ‘ciphers‘

看报错本以为是一个简单的传参问题,没想到查到盘丝洞。

python 复制代码
# 报错信息
wrap_socket() got an unexpected keyword argument 'ciphers'
python 复制代码
# 报错代码段
@_exception_handler()
def connect(self):
    u"""连接MySQL数据库"""
    self.config_connect_args()
    if not self.get_conn():
        self.conn = mysql.connector.connect(**self.connect_config)  # 报错行
        self.set_sql_timeout()
        self.init_my_variables()
    return True

此问题在 这里 有说明,我对其总结如下:

python版本 mysql-connector-python版本 结果
2.6.6 2.1.3 正常
2.6.6 2.1.7 报错
2.6.6 8.0.5b1 报错

解决办法:

python 复制代码
# 1.查看当前服务器安装的mysql-connector-python版本号
python
Python 2.6.6
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>> mysql.connector.__version__
'8.0.5b1'
>>> exit()

# 2.查找mysql-connector-python的包名
rpm -qa | grep mysql
mysql-connector-python-8.0.5-0.1.dmr.el6.x86_64

# 3.卸载这个版本
rpm -e mysql-connector-python-8.0.5-0.1.dmr.el6.x86_64

# 4.安装2.1.3版本(注:如果有冲突,看是不是还有其他版本,都卸载掉)
rpm -ivh mysql-connector-python-2.1.3-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:mysql-connector-python ########################################### [100%]

# 5.检测mysql-connector-python的版本是否正确
python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>> mysql.connector.__version__
'2.1.3'
>>> exit()

完工,再测试,就不会有如标题的报错了。

相关推荐
B站_计算机毕业设计之家8 分钟前
豆瓣电影数据采集分析推荐系统 | Python Vue Flask框架 LSTM Echarts多技术融合开发 毕业设计源码 计算机
vue.js·python·机器学习·flask·echarts·lstm·推荐算法
渣渣苏16 分钟前
Langchain实战快速入门
人工智能·python·langchain
lili-felicity25 分钟前
CANN模型量化详解:从FP32到INT8的精度与性能平衡
人工智能·python
数据知道27 分钟前
PostgreSQL实战:详解如何用Python优雅地从PG中存取处理JSON
python·postgresql·json
ZH154558913140 分钟前
Flutter for OpenHarmony Python学习助手实战:面向对象编程实战的实现
python·学习·flutter
玄同76541 分钟前
SQLite + LLM:大模型应用落地的轻量级数据存储方案
jvm·数据库·人工智能·python·语言模型·sqlite·知识图谱
User_芊芊君子1 小时前
CANN010:PyASC Python编程接口—简化AI算子开发的Python框架
开发语言·人工智能·python
白日做梦Q1 小时前
Anchor-free检测器全解析:CenterNet vs FCOS
python·深度学习·神经网络·目标检测·机器学习
那个村的李富贵1 小时前
解锁CANN仓库核心能力:50行代码搭建国产化AIGC图片风格迁移神器
mysql·信息可视化·aigc·cann
喵手1 小时前
Python爬虫实战:公共自行车站点智能采集系统 - 从零构建生产级爬虫的完整实战(附CSV导出 + SQLite持久化存储)!
爬虫·python·爬虫实战·零基础python爬虫教学·采集公共自行车站点·公共自行车站点智能采集系统·采集公共自行车站点导出csv