网上的教程很多,但几乎是无效的,大部分是教大家改
Modole/Setup
文件,大家千万不要这么做,正确的办法如下:有用的话就收藏吧
File "/usr/lib/python3.4/urllib/request.py", line 1244, in unknown_open
raise URLError('unknown url type: %s' % type)
**urllib.error.URLError: **
>>> import ssl
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/python3/lib/python3.6/ssl.py", line 101, in
import _ssl # if we can't import it, let the error propagate
**ModuleNotFoundError: No module named '_ssl'**
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
yum install wget
cd /usr/local/src
wget https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1q.tar.gz
tar -zxvf openssl-OpenSSL_1_1_1q.tar.gz
cd openssl-OpenSSL_1_1_1q/
./config --prefix=/usr/local/openssl
make && make test && make install
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/
openssl version
wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz
tar -zxvf Python-3.10.6.tgz
cd Python-3.10.6/
./configure -C --with-openssl=/usr/local/openssl-1.1.1q --with-openssl-rpath=auto --prefix=/usr/local/python3
make -j8
make altinstall
ln -s /usr/local/python3/bin/python3.10 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip3
python3 -V
ssl
及_ssl
是否安装成功[root@tj1-miui-apm-vm031 bin]# python3
Python 3.10.6 (main, Sep 6 2022, 06:59:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> import _ssl