娃哈哈好喝-真的!
技术够用就行,吃好喝好睡好!

centos7安装python3.10

pyhton新版本中使用requests请求时会报这样的错误

SSLError("Can't connect to HTTPS URL because the SSL module is not available

网上找的解决办法是在pip后加参数

-i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

类似这样,这样是可以安装第三方库,但是在使用requests库https请求时还是会报上面的错误,http不会,所以还是要从根本上解决此问题。

解决办法:

1、安装openssl3
[root@centos dl]# wget https://www.openssl.org/source/openssl-3.0.2.tar.gz --no-check-certificate
[root@centos dl]# tar -zxvf openssl-3.0.2.tar.gz
[root@centos dl]# cd openssl-3.0.2/
[root@centos openssl-3.0.2]# ./Configure --prefix=/usr/local/openssl
Can't locate IPC/Cmd.pm in @INC (@INC contains: /data/dl/openssl-3.0.2/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /data/dl/openssl-3.0.2/external/perl/Text-Template-1.56/lib) at /data/dl/openssl-3.0.2/util/perl/OpenSSL/config.pm line 18.
BEGIN failed--compilation aborted at /data/dl/openssl-3.0.2/util/perl/OpenSSL/config.pm line 18.
Compilation failed in require at ./Configure line 23.
BEGIN failed--compilation aborted at ./Configure line 23.
[root@centos openssl-3.0.2]# 

如果不出意外的话意外已经来了,如果你跟我一样出现上面的报错,那么需要安装perl-CPAN:

[root@centos openssl-3.0.2]# yum -y install perl-CPAN
# 安装完成之后再继续执行
[root@centos openssl-3.0.2]# perl -MCPAN -e shell
CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.
# 这里输入yes
Would you like to configure as much as possible automatically? [yes] yes

 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
# 这里输入manual
 [local::lib] manual

Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose some CPAN mirror
# 再输入yes
sites for you? (This means connecting to the Internet) [yes] yes
Trying to fetch a mirror list from the Internet
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/MIRRORED.BY

Looking for CPAN mirrors near you (please be patient)
.. done!

New urllist
  http://www.cpan.org/

Autoconfiguration complete.

commit: wrote '/root/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]>
# 安装需要的模块
cpan[1]> install IPC/Cmd.pm

出现这样的说明IPC/Cmd.pm安装成功了

Appending installation info to /usr/lib64/perl5/perllocal.pod
  BINGOS/IPC-Cmd-1.04.tar.gz
  /usr/bin/make install  -- OK

cpan[2]> 

按Ctrl+D退出cpan,继续返回安装openssl3

[root@centos openssl-3.0.2]# ./Configure --prefix=/usr/local/openssl
Configuring OpenSSL version 3.0.2 for target linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Running configdata.pm
Creating Makefile.in
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL.md file first)      ***
***                                                                ***
**********************************************************************
[root@centos openssl-3.0.2]# make && make install

安装成功后还需要做如下操作

[root@centos openssl]# pwd
/usr/local/openssl
[root@centos openssl]# ls
bin  include  lib64  share  ssl
[root@centos openssl]# cp -rf lib64/ lib

openssl安装完成

2、安装python3.10

python3.10.10

https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tar.xz

在这里下载需要的版本:https://www.python.org/

# 安装依赖
[root@centos dl]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
[root@centos dl]# ls
openssl-3.0.2  openssl-3.0.2.tar.gz  Python-3.10.6.tar.xz
[root@centos dl]# tar -xvf Python-3.10.6.tar.xz
[root@centos dl]# cd Python-3.10.6/
[root@centos Python-3.10.6]# ./configure  --with-openssl=/usr/local/openssl --with-openssl-rpath=auto
[root@centos Python-3.10.6]# make && make install

如果不出意外的话就安装完成了

赞(0)
未经允许不得转载:娃哈哈好喝 » centos7安装python3.10
分享到: 更多 (0)