解决_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  # 成功了
相关推荐
Stream_Silver16 分钟前
【Agent学习笔记3:使用Python开发简单MCP服务】
笔记·python
穿过锁扣的风21 分钟前
零基础入门 Python 爬虫:从基础到实战,爬取虎扑 / 豆瓣 / 图片全掌握
开发语言·爬虫·python
Stream_Silver25 分钟前
【Agent学习笔记2:深入理解Function Calling技术:从原理到实践】
笔记·python
love530love44 分钟前
技术复盘:llama-cpp-python CUDA 编译实战 (Windows)
人工智能·windows·python·llama·aitechlab·cpp-python·cuda版本
逄逄不是胖胖2 小时前
《动手学深度学习》-60translate实现
人工智能·python·深度学习
橘颂TA2 小时前
【测试】自动化测试函数介绍——web 测试
python·功能测试·selenium·测试工具·dubbo
爱学习的阿磊2 小时前
Python上下文管理器(with语句)的原理与实践
jvm·数据库·python
m0_736919102 小时前
Python面向对象编程(OOP)终极指南
jvm·数据库·python
one____dream2 小时前
【网安】Reverse-非常规题目
linux·python·安全·网络安全·ctf
冷雨夜中漫步2 小时前
python反转列表reverse()和[::-1]哪个效率更高
开发语言·python