I.ケース
[root@instance-38r7isl1 Python-3.7.0]# python3
Python 3.7.0 (default, Feb 21 2020, 16:38:35)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python3/lib/python3.7/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
>>>
問題解決方法
(1)./Modules/_ssl.c:57:25:エラー:opensslの / rsa.h:そのようなファイルやディレクトリはありません
解決策:opensslのバージョン:バージョンのOpenSSLをチェック
[root@instance-38r7isl1 Python-3.7.0]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
- プレミアムバージョンをダウンロードしてください:(ディレクトリは/ usr / local / opensslの)
[root@instance-38r7isl1 openssl] wget https://www.openssl.org/source/openssl-1.1.1-pre8.tar.gz
[root@instance-38r7isl1 openssl] tar -vxzf openssl-1.1.1-pre8.tar.gz
- インストールコンパイルのopenssl
[root@instance-38r7isl1 openssl-1.1.1-pre8] ./config --prefix=/usr/local/openssl no-zlib
[root@instance-38r7isl1 openssl-1.1.1-pre8] make
[root@instance-38r7isl1 openssl-1.1.1-pre8] make install
- コンフィギュレーション・ソフトウェア接続
[root@instance-38r7isl1 openssl-1.1.1-pre8] ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl
[root@instance-38r7isl1 openssl-1.1.1-pre8] ln -sf /usr/local/openssl/include/openssl /usr/include/openssl
- 修正モジュールのpython3のインストールディレクトリのセットアップファイルとSetup.distファイル、フォルダ、関連する構成SSLを開き、SSLディレクトリを変更します
# Socket module helper for socket(2)
_socket socketmodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/openssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
# The crypt module is now disabled by default because it breaks builds
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).
#_crypt _cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems
- 再インストールコンパイルのpython3
[root@instance-38r7isl1 Python-3.7.0]# ./configure --prefix=/usr/local/python3
[root@instance-38r7isl1 Python-3.7.0]# make
[root@instance-38r7isl1 Python-3.7.0]# make install
- テストが完了すると
[root@instance-38r7isl1 Modules]# python3
Python 3.7.0 (default, Feb 21 2020, 17:27:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
(2)のOpenSSLエラー負荷は共有ライブラリつつ:libssl.so.1.1
ローディング共有ライブラリ中にエラー:libssl.so.1.1は:そのようなファイルまたはディレクトリ番号:共有オブジェクトファイルを開くことができないは/ usr / local /用のOpenSSL / binに/ OpenSSLを
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1