[已解决]pip is configured with locations that require TLS/SSL, however the ssl module in Python is not

在CentOS系统上,由于需要使用Python3操作MySQL数据库并导入pymysql、requests和ssl库,但在安装过程中遇到pip提示缺少ssl模块。文章详细介绍了如何在Python2和Python3共存的情况下,编译Python3时解决ssl模块缺失的问题,包括修改Makefile配置,更新动态链接库路径,并成功安装所需库。

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

一、问题背景

CentOS系统上需要通过Python脚本操作MySQL数据库,脚本中需要import pymysql、requests、ssl等Python库,准备通过pip安装。

系统默认已安装Python,版本信息如下:

CentOS release 6.5 (Final)

Python 2.6.6

但因为种种原因,数据库脚本需要使用Python3,而系统yum等命令又依赖于原2.6.6版本,所以造成系统上需要Python 2.6.6和3两个版本并存本文就是介绍如何在上述系统背景下,再安装支持ssl的Python3

 

二、问题描述

第一遍编译安装Python3.6的步骤如下:

#先安装相关包:

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

#下载并编译Python3:

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

tar -xvJf  Python-3.6.2.tar.xz

cd Python-3.6.2

./configure prefix=/usr/local/python3

make && make install

mv /usr/bin/py
当你看到警告信息 "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available" 时,这意味着你的Python环境缺少SSL模块,导致pip无法正常使用TLS/SSL。这可能是由于你的Python版本不满足要求或者缺少相关依赖库所导致的。 解决这个问题有几种方案: 1. 升级Python版本: 如果你的Python版本过旧,可以尝试升级到较新的版本,因为较新的Python版本通常会自带SSL模块。 2. 安装依赖库: 检查你的系统是否缺少必要的依赖库,例如OpenSSL。你可以尝试安装相应的依赖库,然后重新编译和安装Python。 3. 使用虚拟环境: 如果你不想改变全局Python环境,你可以考虑使用虚拟环境来管理你的项目。虚拟环境可以独立于全局Python环境进行配置,从而避免了全局环境的影响。 综上所述,你可以尝试升级Python版本、安装相关依赖库或者使用虚拟环境来解决 "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available" 这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [解决 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not](https://blog.youkuaiyun.com/qq_49580107/article/details/126380616)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *3* [pip is configured with locations that require TLS/SSL](https://blog.youkuaiyun.com/TomorrowAndTuture/article/details/119989736)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值