我正在尝试在 CentOS 7 上安装 Python 3.7 并升级 Python 使用的 SSL 包。我升级了 openssl 并拥有这个版本...
(venv) [rails@server Python-3.7.0]$ openssl version -a
OpenSSL 1.1.1g 21 Apr 2020
built on: Thu May 7 19:18:59 2020 UTC
platform: linux-x86_64
options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/openssl"
ENGINESDIR: "/usr/local/openssl/lib/engines-1.1"
Seeding source: os-specific
我下载了 Python 3.7 源代码并像这样编辑了 Modules/Setup.dist
# 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
我像这样配置并安装
./configure CPPFLAGS="-I/usr/local/openssl/include" LDFLAGS="-L/usr/local/openssl/lib"
make
make install
make 似乎成功完成,但产生以下警告......
...
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_lzma _tkinter _uuid
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc atexit pwd
time
running build_scripts
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/pydoc3 -> build/scripts-3.7
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/idle3 -> build/scripts-3.7
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/2to3 -> build/scripts-3.7
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/pyvenv -> build/scripts-3.7
changing mode of build/scripts-3.7/pydoc3 from 664 to 775
changing mode of build/scripts-3.7/idle3 from 664 to 775
changing mode of build/scripts-3.7/2to3 from 664 to 775
changing mode of build/scripts-3.7/pyvenv from 664 to 775
renaming build/scripts-3.7/pydoc3 to build/scripts-3.7/pydoc3.7
renaming build/scripts-3.7/idle3 to build/scripts-3.7/idle3.7
renaming build/scripts-3.7/2to3 to build/scripts-3.7/2to3-3.7
renaming build/scripts-3.7/pyvenv to build/scripts-3.7/pyvenv-3.7
(venv) [rails@server Python-3.7.0]$
然而,当我运行Python时,它仍然显示旧版本......
[rails@server Python-3.7.0]$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2k-fips 26 Jan 2017
我还需要做什么才能让 Python 识别正确的 openssl 包?