ImportError: libssl.so.10: cannot open shared object file: No such file or directory

介绍


Python项目在Centos上移植到Ubuntu系统时,启动发生错误
Python项目在CentOS上时是编译安装的Python环境
Ubuntu上自带Python3.8

启动时发生错误


import _ssl # if we can’t import it, let the error propagate
ImportError: libssl.so.10: cannot open shared object file: No such file or directory

Traceback (most recent call last):
  File "/home/leenhem/code/OpsGuide/main.py", line 2, in <module>
    import tornado.httpserver
  File "/home/leenhem/code/OpsGuide/tornado/httpserver.py", line 29, in <module>
    import ssl
  File "/home/leenhem/code/OpsGuide/python/lib/python3.7/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: libssl.so.10: cannot open shared object file: No such file or directory

错误原因分析


新环境中的Python没有把ssl模块编译进去
我们需要在新的环境中重新安装Python环境并把ssl模块编译进去

重新编译Python环境


下载Python
https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz

sudo apt-get install libssl-dev
sudo apt-get install libffi-dev

tar -xvf Python-3.8.0.tar.xz
cd Python-3.8.0
./configure -prefix=/usr/local/python3.8
make
sudo make install

主要就是要重新编译
重新编译时要在系统上安装上libssl-dev,libffi-dev分别是对__ssl ,__ctypes 的支持

版权声明:本文为作者原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原创文章,作者:老C,如若转载,请注明出处:https://www.code404.icu/1398.html

发表评论

登录后才能评论