Centos7 使用 pip 命令来安装 mysql-connector

本文介绍了解决pip在安装mysql-connector时遇到的SSL模块不可用的问题。通过更改pip的配置文件,使用阿里云镜像源,成功解决了因TLS/SSL问题导致的安装失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

执行命令:

[root@localhost ~]# pip install mysql-connector

报错信息(部分缺省):

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting mysql-connector
 ......
  Could not fetch URL https://pypi.org/simple/mysql-connector/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/mysql-connector/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement mysql-connector (from versions: )
No matching distribution found for mysql-connector
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

报错的原因主要是 pip配置的下载镜像有问题

解决方法:
1.创建~/.pip/pip.conf

[root@localhost ~]# mkdir ~/.pip
[root@localhost ~]# cd ~/.pip
[root@localhost .pip]# vim pip.conf

2.配置pip.conf

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
disable-pip-version-check = true
timeout = 120
[install]
trusted-host=mirrors.aliyun.com
ignore-installed = true
no-dependencies = yes

3.验证

[root@localhost .pip]# pip install mysql-connector

在这里插入图片描述
安装成功!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值