解决_ssl.so: cannot open shared object file: No such file or directory

背景:

我在CentOS8.2的操作系统里安装完python2.7后,源码安装了OpenSSL_1_1_1-stable

下载地址:

https://github.com/openssl/openssl/tree/OpenSSL_1_1_1-stable

现象:

结果python导入ssl的时候报错了,报找不到_ssl.so这个库文件

python 复制代码
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: /usr/local/lib/python2.7/lib-dynload/_ssl.so: cannot open shared object file: No such file or directory

分析:

_ssl.so这个库文件找不到,是因为安装完OpenSSL_1_1_1-stable后,要再安装一次python,并且编译命令如:

python 复制代码
./configure --with-ssl-default-suites=openssl --with-ensurepip=install
make altinstall

python 编译完成之后,才会在python2.7/lib-dynload 的目录下生成 _ssl.so 文件。这样再import就没问题了。

解决:

我不去手动编译了,全用yum 命令来吧。

python 复制代码
yum install openssl-1:1.1.1k openssl-devel-1:1.1.1k libssl-dev
yum install python27

>>> import ssl  # 成功了
相关推荐
try2find23 分钟前
安装llama-cpp-python踩坑记
开发语言·python·llama
小小鱼儿小小林1 小时前
免费一键自动化申请、续期、部署、监控所有 SSL/TLS 证书,ALLinSSL开源免费的 SSL 证书自动化管理平台
开源·自动化·ssl
博观而约取1 小时前
Django ORM 1. 创建模型(Model)
数据库·python·django
精灵vector3 小时前
构建专家级SQL Agent交互
python·aigc·ai编程
Zonda要好好学习3 小时前
Python入门Day2
开发语言·python
Vertira3 小时前
pdf 合并 python实现(已解决)
前端·python·pdf
太凉3 小时前
Python之 sorted() 函数的基本语法
python
项目題供诗3 小时前
黑马python(二十四)
开发语言·python
晓13134 小时前
OpenCV篇——项目(二)OCR文档扫描
人工智能·python·opencv·pycharm·ocr
是小王同学啊~4 小时前
(LangChain)RAG系统链路向量检索器之Retrievers(五)
python·算法·langchain