|
|
centos7.9安装python3.10版本
, C8 r$ H9 q L+ E' n先下载python3.10版本$ T3 x" z# g& }" P) W) ?6 t! z
7 ^# m0 p8 |# j7 S5 a7 e6 p
Python 3.10要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上
3 G! U/ Y+ E% _( O% mwget https://www.openssl.org/source/openssl-1.1.1k.tar.gz7 }- r) l- ]5 D
--2025-08-08 23:02:41-- https://www.openssl.org/source/openssl-1.1.1k.tar.gz1 o# C& q4 j8 Q# p! l! {
Resolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b::
5 t3 F {( z: {# J7 e5 v3 e# x; {Connecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.5 K# A- \( Q X
HTTP request sent, awaiting response... 301 Moved Permanently1 t* Q7 z( Q0 ]' P
Location: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]' a5 U' U' P/ C
--2025-08-08 23:02:43-- https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz
: b" s1 _/ ]# U9 |* T1 XResolving github.com (github.com)... 20.205.243.166
! b! |: |. O( |7 _# |9 P0 ~Connecting to github.com (github.com)|20.205.243.166|:443... connected.
" M2 y, F) R7 w& I. v p( U% [HTTP request sent, awaiting response... 302 Found, F/ E/ W; r: ]9 @! C/ Q
Location: https://release-assets.githubuse ... tion%2Foctet-stream [following]
( G' c0 e. f _( f, _--2025-08-08 23:02:43-- https://release-assets.githubuse ... tion%2Foctet-stream3 D( F* N$ V4 u8 K3 f9 g$ d
Resolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...
( ^: _. h8 |6 }/ ]& ^! `Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected. s+ m) h6 \2 P
HTTP request sent, awaiting response... 200 OK
9 `5 |: O' Z6 wLength: 9823400 (9.4M) [application/octet-stream]
+ e8 d2 v8 W4 R1 r; x' RSaving to: ‘openssl-1.1.1k.tar.gz’, T) O9 `) x% s" @
$ u1 s6 y% i0 P6 D, P
" s' n0 I- s7 ?9 ?* ^" F100%[=====================================================================================================================================================================================================>] 9,823,400 203KB/s in 44s
9 O* r- [' [3 r4 b# B6 Y: l* a2 A) \. ]" B/ N3 N2 ?$ x! _3 U. }7 Q! Q
- s8 {" Z3 C% c" D2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]- _) }* A' f, c
( Y3 g- g) Z3 ~! ~4 M3 r# e
6 G- [; M5 Z' d: j+ g( ]. C3 c! B
备份文件:
5 a' ^ T# @6 V) u# P# C! t
' i T8 ^+ T* a# l l4 R* h. ^# mv /usr/bin/openssl /usr/bin/openssl.bak$ L' [+ V/ Q; f3 o# s' W
$ N! S% y5 n- ^* d) h) s& P
" d ^* p. b3 e/ J
0 \! ]& Q0 Z. B: t# G% }# x
# mv /usr/include/openssl /usr/include// @$ p9 t0 V3 s4 L/ t- \& T
Display all 163 possibilities? (y or n)
* @9 z, p3 l1 u+ n# mv /usr/include/openssl /usr/include//openssl.bak: W% c6 f6 D. |( b7 Z7 D+ [1 G
3 N; a1 n9 d7 X2 A+ V/ k* g
% ?1 j: h Y% P) D$ Q/ l! w9 |3 _解压openssl
# n, @* Q, V% [# @ ]# tar -zxvf openssl-1.1.1k.tar.gz
/ a. e6 `" P: A4 |. b" F8 q4 i4 N$ D, ~ S6 O$ r4 D0 |% x
: p, N: F6 Q* K. V1 y. T6 L2 n1 @3 j1 r# ]# cd openssl-1.1.1k/# n, _8 l# j" S4 V
# mkdir build Z' k. T1 x# C; v% ?; [
# cd build/$ s5 l: F6 V! r9 {' E/ f7 E
m, n4 j s% i6 c
# ../config --prefix=/usr/local/openssl4 W# `- V5 B Q7 g
Operating system: x86_64-whatever-linux2$ P8 w3 K5 o6 F7 e( u# C
Configuring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64
6 {: {# H" L) e7 a/ ?# hUsing os-specific seed configuration6 o# |+ P9 {8 H
Creating configdata.pm* U; _. e; W& M5 D; L. {
Creating Makefile
' G4 `5 H; |4 a. S) [. M
* V0 G3 X, A b. ^* J: t# u; |' P
**********************************************************************( g4 \5 u" q& u+ Z- d, }: H
*** ***0 ~ s# ]6 f1 t' h N- K# ?
*** OpenSSL has been successfully configured ***' Z7 q3 ?- c/ ^- O, N5 v
*** ***$ Q! z" | W/ i6 z; E
*** If you encounter a problem while building, please open an ***& H$ l% k/ h1 }# D z% E7 O0 x' q
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***% Q: v" k6 V6 P3 U3 K3 v# {
*** and include the output from the following command: ***1 y/ ?0 Y, d7 O
*** ***2 c0 \% z n) x7 R, z5 }
*** perl configdata.pm --dump ***
/ L3 ^4 i$ L, J y*** ***' A% L, ~: P, D/ c( T
*** (If you are new to OpenSSL, you might want to consult the ***
) u; c. z; a ^- t K4 j- p% C, e. t& Y*** 'Troubleshooting' section in the INSTALL file first) ***
3 [0 v3 G8 V+ f |*** ***" ^/ a" v$ d' j# N, Y
**********************************************************************
+ |9 d9 o! T& s& Q
- P! F- d9 j6 Y* a# make -j && make install, ^- k3 m$ Q1 C( `' @! x$ L
, ]) E: l+ I# r- E4 }2 v# I, v- L5 c0 v0 g& Q7 M% l
# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf5 k' C4 ^; F3 O
# ldconfig -v1 j/ b: E' _8 O! F" g6 n$ e; b
ldconfig: Can't stat /libx32: No such file or directory+ d# u" \2 C, n" O
ldconfig: Path `/usr/lib' given more than once
2 T I! @; h a5 aldconfig: Path `/usr/lib64' given more than once
& L. \" A o& o+ m% bldconfig: Can't stat /usr/libx32: No such file or directory
' [6 O& S# v% G P/usr/lib64//bind9-export:
. E J! X8 c4 _ e libisccfg-export.so.160 -> libisccfg-export.so.160.2.1
8 H/ u& m" W0 D6 {
2 b* M3 a6 M6 {3 D2 y$ z% a# openssl version
4 O Q( @8 K2 v7 C7 gOpenSSL 1.1.1k 25 Mar 20215 u$ I* [% a i
! {; l1 m" n$ @3 x( J, V$ J1 [/ q8 z2 ~ P
接下来安装python3.12.10和pip3
& s4 J7 r E( J7 Y8 i; w下载python3.12.7源代码0 t! c- c( C5 b) w* t2 ?
# tar -zxvf Python-3.12.10.tgz0 k9 t: D/ |- \! B& j1 J1 s3 Y
" Z5 w$ K) G; A4 q, S# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
- l. S$ E3 j; P/ A# Q7 T: G* v1 S0 e
" q( |9 S$ I$ U: t5 c
7 m1 C# E6 c+ {5 X
4 b3 a& A* h% _; x
8 g$ f2 Z/ |' c2 q K8 o, @: t! [7 i; t3 z
进入解压后的源代码目录9 k( |5 ]* C, `0 @* z8 v3 D6 \
; x1 W$ \ f9 s9 c( z( O
# cd /usr/src/Python-3.12.10/
0 b1 y! t" F3 i* h4 d$ c7 n: [0 V: x* F: L
1 V8 g: _, g* W( o# a. L' ~/ ~
7 X5 ^( t; H+ \# p) C8 t C% Y
6 u& j' J: l& K5 q
配置
, W: s% B. [) \$ B9 j# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl% x6 s! s) f+ ?! ^8 R: h& _
. m! L8 M* d* a0 Q4 n0 I- @9 P; c5 I5 g; G4 o t
编译8 p+ W8 Y6 q3 y6 i; q
make( o* J. G7 S& i6 t7 M- C" r O! t1 o
安装) Z+ r9 [; a# G3 o" ~+ I9 r8 Q" P
make install5 Y* b1 i+ s9 f9 g- g/ \7 r
. R+ b5 D( {) W" Q
' \: a" b8 Q6 {9 m& l8 X+ E( M( ?: }' s6 w
# make && make install: e, i3 j8 w* w
gcc -std=gnu11 -pthread -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
6 H3 v3 T/ A ]$ I$ S- _" s! lgcc -std=gnu11 -pthread -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Parser/token.o Parser/token.c
, k; s8 O) o1 U; Ngcc -std=gnu11 -pthread -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Parser/pegen.o Parser/pegen.c
1 {# w5 g) [) y. X6 x4 ^; Xgcc -std=gnu11 -pthread -c -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Parser/pegen_errors.o Parser/pegen_err
" r9 h/ Q9 c9 A+ c) j# _7 l. [+ o2 a$ z% d
$ E% a, k; ?5 \$ t8 k
0 l8 u, V* t: \: L% V创建软链接
* t( A9 s, V s( j6 B7 M6 x: Q! rln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3
9 _; ^" ?% ?0 n) W7 n7 Jln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3( X, n- ~* E# Q
. f8 u0 ^9 D2 o8 _7 l% I
8 s6 w' ]6 s2 j/ N' u验证python3及pip36 ^9 s, {7 f6 Z" Q- f1 O0 w) Q- C
[root@centos7 Python-3.12.7]# python3 --version
. j0 G% U: f2 h4 q0 |- gPython 3.12.7
0 E4 X# ` b8 H8 q1 s6 i' \[root@centos7 Python-3.12.7]# pip3 --version
5 i( \5 A% r9 i3 }5 Cpip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12)
* X5 ^0 t: @! G2 J+ t' y6 d. C- g J
bash
& E* _% q5 d/ z5 R5 a9 y0 M3 l' Q- X- I0 k" D5 [
& @0 o# S: R3 p7 s! K1 B |
|