|
|
centos7.9安装python3.10版本4 r5 y2 w3 W [6 l9 h
先下载python3.10版本* i p; S0 }% D( ?5 n
e5 v I4 q% Q8 P' ^Python 3.10要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上
* n2 t; W' ]4 hwget https://www.openssl.org/source/openssl-1.1.1k.tar.gz& I& v( o1 R Q2 Q. S2 q
--2025-08-08 23:02:41-- https://www.openssl.org/source/openssl-1.1.1k.tar.gz3 w) L( a( H5 Y3 {
Resolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b::
& V i9 p7 Z* T/ r4 b' n- g% BConnecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.. o8 _! w* i9 ^" z: C
HTTP request sent, awaiting response... 301 Moved Permanently
7 J. E- q ?: f: C9 p5 NLocation: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]/ D+ l5 W1 P* b3 O* c5 C W5 w
--2025-08-08 23:02:43-- https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz' L/ n8 x& S/ y* @, v) c+ I: r$ E
Resolving github.com (github.com)... 20.205.243.166! ?: b0 B& \0 w' j( t* x
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
1 @4 Y& b; ^- C! THTTP request sent, awaiting response... 302 Found
6 ], Y# k ]) j+ }+ j5 WLocation: https://release-assets.githubuse ... tion%2Foctet-stream [following]( H; l, T! M$ _$ \$ B
--2025-08-08 23:02:43-- https://release-assets.githubuse ... tion%2Foctet-stream
6 m( w! Q3 F( |+ F* B' x2 NResolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...
* f9 G, K) W( v: n" z; {Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected.
9 ^, H( v& z; n5 HHTTP request sent, awaiting response... 200 OK( P. W& h- m' ?
Length: 9823400 (9.4M) [application/octet-stream]
m z g6 B3 }! C2 vSaving to: ‘openssl-1.1.1k.tar.gz’
+ ^0 d. R$ i$ ]
& F9 _$ d; d7 v" F
+ U) N& E, K' R+ ~9 I6 W100%[=====================================================================================================================================================================================================>] 9,823,400 203KB/s in 44s
: q0 c6 t3 v$ e* f% [* u2 v8 c& I1 J% t6 ~& n* j, O
/ e2 T* x9 k& c# Z6 L. Y/ C# v
2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]: v" O" g, I- F- G6 l9 A n- R
3 g0 o. F* I" g7 S
4 T% ?# A3 [1 Z
备份文件:/ T& m9 O( M6 v, A) @4 V
% c4 V1 e5 ^7 S* ^& ]) |- R# mv /usr/bin/openssl /usr/bin/openssl.bak
! x) F! k4 o l, y& t& _. L; g ]6 M/ Q- q
/ B* f+ q2 u; @' e2 s) j
+ d1 [- |! u3 m/ \# E# mv /usr/include/openssl /usr/include/, R8 e. c, z, M& a
Display all 163 possibilities? (y or n)
. L* N. Q# n2 ?# mv /usr/include/openssl /usr/include//openssl.bak
" g( ^# d8 n7 f$ p& Y- i% {4 X. l5 u y3 ?
2 N$ L/ @* m+ E. S( B. i8 x解压openssl7 S, n) V) w1 Y, |9 k+ z$ [
# tar -zxvf openssl-1.1.1k.tar.gz
/ I) |# g8 ^: t' ?( F; [( M. {8 x/ D
% I6 Z. f' C" `9 V1 r; ^0 J
# cd openssl-1.1.1k/( _4 X& \5 ~# p3 O$ J T2 X- T
# mkdir build# e( K7 X _6 b8 {
# cd build/$ H& e' P2 n: C# g3 H
# H" O& [9 d2 ^
# ../config --prefix=/usr/local/openssl; }% m; s* @0 k6 M, I8 F3 s5 k
Operating system: x86_64-whatever-linux2
; G, T7 d& p" yConfiguring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64
! l% q+ s5 N8 [; w* _. [Using os-specific seed configuration
% C. d6 ?. H+ rCreating configdata.pm
- F5 B! R2 d6 I% y/ yCreating Makefile5 P' I, e9 B0 ?4 a6 }! N
: G( V+ J6 u8 k- v$ ?" j w2 `# l- [, t
**********************************************************************+ k# L. [( T* A$ Q' }/ g8 F: c
*** ***
/ ^8 w6 [% ?! o* L9 ~5 i; I*** OpenSSL has been successfully configured ***! P1 |2 B* c$ m
*** ***
$ z' X- I* p& J0 P1 i' s0 q*** If you encounter a problem while building, please open an ***- x+ ]1 Y) M& ]9 @
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
: \0 M$ ^) [3 Q*** and include the output from the following command: ***
- f7 U1 [4 \1 J' C5 x& o6 S*** ***3 z! d) X! L7 B0 _. x) T) x
*** perl configdata.pm --dump ***
0 n( l. n2 i# n2 L, W! y*** ***
% L5 O0 v' Z7 S7 p2 u( w: r& @*** (If you are new to OpenSSL, you might want to consult the ***
; V+ J8 v* J" [8 j! N*** 'Troubleshooting' section in the INSTALL file first) ***& m+ f6 m) I$ N; E: i+ o& J$ l
*** ***; K! }1 G8 |$ c1 M; f3 J3 ~
**********************************************************************
) S m2 l& |; K8 k# f+ N6 N) K
# make -j && make install. d/ k& Y/ D6 N/ P
5 d% y% [6 |3 l. r# y4 H u$ q/ p( w9 |7 ]. f: G8 S) `+ u
# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
6 U6 A# a+ a8 ~) Y) H. l7 H# ldconfig -v
. v( C7 S6 K2 o4 s) O2 Xldconfig: Can't stat /libx32: No such file or directory
3 H+ T2 G' C' n8 X$ Cldconfig: Path `/usr/lib' given more than once
0 ]0 C f' {/ R9 M: d. j2 ~ldconfig: Path `/usr/lib64' given more than once
3 Q) P+ O% ?$ Gldconfig: Can't stat /usr/libx32: No such file or directory
9 G$ [0 z% I" R' b" {/usr/lib64//bind9-export:, [' \; q1 M- B2 Y- Z( e
libisccfg-export.so.160 -> libisccfg-export.so.160.2.13 _) p; `7 b1 [ Z2 Z
) p# z! f+ }3 b3 a& f# B
# openssl version& g+ d9 R) K; I/ N0 q/ _
OpenSSL 1.1.1k 25 Mar 20213 q2 |& `+ K; ~9 `3 y4 M" V
) R5 G7 O% N. k, I! U. j) l5 s8 s* x7 X
接下来安装python3.12.10和pip3
, }3 r( }2 T+ ^( U7 [下载python3.12.7源代码
+ c; Y. w* N$ N& z4 i, U0 p# tar -zxvf Python-3.12.10.tgz; u# a# W# h: Z: e
, ]3 {1 Q. w( @% m. H1 N( r2 f# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
0 H8 U/ w' O8 l. H$ n9 `8 x- D V4 e, \/ Y& g& g# \9 F
& z- ?8 E; f, T- M+ F9 a
/ h5 p1 X: Q C# ?( v! K
9 n: F- Q$ @: P1 Y4 e3 n1 r2 C) N/ X* h& `( M' D% m
进入解压后的源代码目录
3 K8 i% |) i( Z' ~! W+ [/ D) S0 t& F& ]
# cd /usr/src/Python-3.12.10/6 ?. f2 M( D" n5 Q1 t
5 M& e( H, t# \# l9 z" u) u5 E$ n. t; |2 M, C. \, |$ u; G
/ O. ^: q4 Z( E
6 o" |0 x/ l8 C1 j: f
配置
+ p0 A$ `$ U' y$ W: j# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl
. j8 t- \2 Y6 i6 J. F
. ^4 h2 Q! M2 K2 N* z0 p
( i2 V; j: X) Q. U% B8 ^6 A编译1 b: I; H- B- O9 F1 G i
make9 l# S) Y: `; C
安装. n6 p0 q5 c1 O8 S
make install9 @) E2 B4 A* j- S+ a
1 a- }: b8 S) N+ G7 z8 o; s2 b3 o2 M& G
4 N4 G9 g' f7 T9 v. @( O, j% |/ J6 e# make && make install) o* }. p% e$ z6 @
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
! {& E9 x( D6 t) kgcc -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.c1 Y8 Q- Q- d ?( H7 o
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 Parser/pegen.o Parser/pegen.c
7 Y+ R2 x: e7 P$ jgcc -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% E3 I3 v- X# h7 s) Q' l! T, S s
0 {" j5 R; M9 Q
% m0 j S% u( r& M' \* s
# u* ~# |! @9 \3 r2 a5 ^
创建软链接& Z; C+ X6 l4 |/ S) U( t
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3
1 a. G4 |, I; N4 ]7 h; _ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3: m4 [7 H# e' i# I% q o# _: a
) `0 ?4 G+ n0 J# u: l, Q* _* {
" o l- x4 y" J8 T& {* a2 T验证python3及pip3' v1 N/ k2 \9 p2 V
[root@centos7 Python-3.12.7]# python3 --version
3 }6 R% u9 A) sPython 3.12.7; |1 w+ b5 R9 Z1 g' q! r( _
[root@centos7 Python-3.12.7]# pip3 --version# Z9 }- ]* p$ X* G
pip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12)2 V4 k8 J/ R, e
4 V9 ^1 I' e4 g* f B$ Ebash5 H7 g9 {/ E- d$ A+ f% C* f
. P/ \% {& Z- L0 ]
: a* L r+ q" k9 C! `4 [+ V; b |
|