|
|
centos7.9安装python3.12版本* }* n9 }1 s$ D. ?. k
' _5 G$ n/ I' i1 {. Q4 _3 z" i/ q. q
Python 3.12要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上
# V6 ^; V; {0 x/ C! X wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz' ]& {1 S3 S; b5 i1 [, p
--2025-08-08 23:02:41-- https://www.openssl.org/source/openssl-1.1.1k.tar.gz! B0 S2 a; C/ \4 K; s
Resolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b::. E W# r' ?" M
Connecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.
: q/ ~$ @4 B; y! y7 B7 JHTTP request sent, awaiting response... 301 Moved Permanently8 a" Y" I4 g( Q6 a n7 M5 q: x
Location: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]
/ M: T8 {4 j' q! N; ~- [. Z" `) |6 X--2025-08-08 23:02:43-- https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz( h0 ~( h" Z% K
Resolving github.com (github.com)... 20.205.243.166
( L2 }4 ]5 Y5 H" s B; ]% B0 `7 xConnecting to github.com (github.com)|20.205.243.166|:443... connected.
7 r; \% g7 ^/ o0 g( `) LHTTP request sent, awaiting response... 302 Found
) [/ X6 E, h8 O6 N5 v6 E3 ALocation: https://release-assets.githubuse ... tion%2Foctet-stream [following]
) F3 ^3 A4 o9 K* Z3 z: Z! F--2025-08-08 23:02:43-- https://release-assets.githubuse ... tion%2Foctet-stream
/ f5 p2 C" T5 U/ _+ d. R& yResolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...9 e+ `. a$ h% h% y2 g/ o, A/ g' n
Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected.
( c1 h3 G4 T4 }' A7 iHTTP request sent, awaiting response... 200 OK4 g4 D2 d3 V$ H: |. t- T& x
Length: 9823400 (9.4M) [application/octet-stream]' I' M% O- ?- k) x6 R+ X$ @3 p
Saving to: ‘openssl-1.1.1k.tar.gz’
3 `" O+ U% H7 V9 P" B7 h" \' ]4 n y( m; s& ^6 E9 o
: U1 P% h; c6 Z- m8 r+ n" d# d100%[=====================================================================================================================================================================================================>] 9,823,400 203KB/s in 44s
! f2 h- j0 v" L! p* N7 R
0 A+ Q o R& G+ \$ D7 c$ {
3 g* N" t9 \8 i7 X: q& W# k2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]8 V: `" o6 } C+ X& e8 ?# R: |
+ ^/ W3 @' m% ]0 \2 G+ I" P* w, b. L; Y; U4 X# S1 J
备份文件:
. q6 e) Y; ]. E: [( q7 Y4 J. Q+ [4 R5 q
# mv /usr/bin/openssl /usr/bin/openssl.bak8 i! K+ ?. x) a' p" B7 R3 t
5 K9 O6 r0 U' i* K- ^9 G
! t3 F+ I- A+ s& G- |4 d* y. @9 X: T! u4 [
# mv /usr/include/openssl /usr/include/
/ u r5 y! b. E" j, t1 w6 kDisplay all 163 possibilities? (y or n)
" S1 U: }, _, U8 U8 p! @/ i# mv /usr/include/openssl /usr/include//openssl.bak
" q2 ^# Y% j8 X, |6 I+ ~. }) J$ p; ~( ^3 h% F( T7 l
3 s! h! N0 X, j8 R3 @
解压openssl0 i" f) {6 P2 g9 K
# tar -zxvf openssl-1.1.1k.tar.gz1 ^) }/ O7 E' X- y* s( S
9 a$ |9 s4 _7 H" q P, [/ W% n5 V9 Z* F Q" z2 ^6 Q+ x
# cd openssl-1.1.1k/5 Z$ `( k1 n2 x Q2 y1 V+ t( x3 d
# mkdir build
9 d/ }8 [4 q9 x( K- G' c6 W0 N# cd build/& [. K4 s8 n; q( w
" H7 t2 @! C6 X# w9 `- F
# ../config --prefix=/usr/local/openssl& U6 z- B, D# X g, d8 a$ H0 C
Operating system: x86_64-whatever-linux2
8 q7 @) f, u2 u0 tConfiguring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_646 k, }: J# F: w% v4 h; h# ]
Using os-specific seed configuration4 K! Y0 l9 r/ i4 i" ?7 n
Creating configdata.pm
/ u1 P5 G! Q {+ j2 `Creating Makefile7 A, S. i$ a2 G% J& r2 ~
( Q% |( G# p9 h; I8 k: a
- i! A; O9 W6 ]" [1 C6 w* |**********************************************************************$ Y" A5 `" N x1 E# p
*** ***4 `/ Y R8 }1 [- e9 n+ g
*** OpenSSL has been successfully configured ***0 y; x( W1 h, E7 S$ \+ h
*** ***# G# j7 x0 A" S1 A! l
*** If you encounter a problem while building, please open an ***1 a4 C! I2 p* i6 |% E: k
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
4 I1 g% B- M; j4 Y$ z*** and include the output from the following command: ***
, y6 e2 K8 k: ~3 c0 O: T0 u*** ***
2 T" x* A5 B6 i4 I2 ], L* j*** perl configdata.pm --dump ***8 C& X: B c3 J2 N9 p0 j( t% Q
*** ***
% x. f- l) E4 E% o( X" V/ J*** (If you are new to OpenSSL, you might want to consult the ***
% g7 Z. h' }, h1 Q, K b) o*** 'Troubleshooting' section in the INSTALL file first) ***
/ `6 V U: r# R*** ***& O; ]& r; K) l( b! L1 ], g% X
**********************************************************************
& E a5 X! S+ R
# W9 |1 }0 L3 A X/ t! _: D# make -j && make install
( \6 w! d6 m ?0 K
$ s/ O `3 h! s" F) B: t$ X0 I8 P% Z! ? n) R( ], r( J& T" N8 t' s
做软连接:
! [- j' i( Q+ H. J2 U w ln -s /usr/local/openssl.1.1.1/bin/openssl /usr/bin/openssl
0 J2 s9 n$ W2 e3 H; v! R* V$ l7 }( d* S4 u* L" Y% m
# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf 1 M d2 l, i6 E9 y3 B) o+ x
# ldconfig -v
% y: F$ O" K: Zldconfig: Can't stat /libx32: No such file or directory
7 t/ Y! w S2 i0 g4 g6 v& Hldconfig: Path `/usr/lib' given more than once1 h% w, M V) n
ldconfig: Path `/usr/lib64' given more than once$ X; R2 W! c) q7 i% s
ldconfig: Can't stat /usr/libx32: No such file or directory
( A: ]0 U) `3 P! @/usr/lib64//bind9-export:
0 l2 a2 C/ l e2 s4 N libisccfg-export.so.160 -> libisccfg-export.so.160.2.1
) T9 N" I2 Q6 s' G `
9 t8 d' w) b0 q) y8 ~3 g9 O0 P# openssl version
+ e1 S+ e& V; a( h; p/ J8 q8 lOpenSSL 1.1.1k 25 Mar 2021
. d6 N3 F6 j$ v* c0 `$ V5 z' V8 Q2 O& `; c: M8 `! `
/ A4 z, q; _' q6 h' S1 a% T接下来安装python3.12.10和pip36 V0 r+ u: Q) b8 [0 d2 Z% N5 b8 T
下载python3.12.7源代码
! W0 c- F( d7 A, O6 S" B! L# I& B' r p+ P# tar -zxvf Python-3.12.10.tgz 7 I+ v3 k. T& D+ f, m! h2 |
$ M6 C2 I3 l8 T% S# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
" ?8 R1 Q: z: |4 P L1 d9 c! N
1 f% G9 \$ T( O) O6 w
4 `, C/ G/ T8 C% J3 H( N% |# Y! C* s
1 c# x3 S7 ^" K* y& P. d. ? j W5 J
4 k8 ^7 {# `8 H4 o进入解压后的源代码目录; T( U/ a* J" E+ {
/ O& j4 P) D, p/ z# cd /usr/src/Python-3.12.10/
7 R# v" ]0 H; ]2 k6 w7 K9 ~0 _6 F# }5 u+ b
* x& v7 f9 w3 {7 w& B: u5 R
: V- {! A8 Q& O1 ]
8 g- J! m" K5 h1 h# x* @9 r5 j' e. B配置( {5 \& x3 P7 t( W4 v9 n. U: b
# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl 6 I1 Z% j( A7 Z. {
0 p* t; R: g2 m3 B% F% ]$ r$ j7 I8 `; A5 @1 R; s4 N
编译1 x! j3 _& ^2 N6 u0 l9 o6 {
make* E9 N$ B- ]/ C& z/ a7 m1 C+ }
安装) r! J) |) Q3 z4 u. r' }' d
make install$ N q# p- n% G/ R; L( B- c4 H
" J& t, I! m/ Z( O) n% l# |, K. B; V: W' w- D% s9 r3 \. v# U
P: f) J6 v1 [# {9 M9 X' y# make && make install # L6 M, P: U" R! ]) T7 V8 v/ N
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+ z; X! }, e+ B$ |4 |- w( q
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/token.o Parser/token.c
+ [2 v' \- ^% ]' N9 g& W4 S4 [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
% w1 Z) d8 C. J3 ]& hgcc -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; m( S7 H; k- b- C
6 ]6 O0 t( J% ~, m% @' z( X
. k* @' f/ b% E* @# T
* w; B# }& d) Q7 g/ `
创建软链接
6 x4 U( b7 W) rln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3, Q R* O* I' x4 C- M3 O
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3
- D9 T9 Z, ^( I5 @! d! W) i) D+ l; i# D1 |; e4 s4 L+ G2 L/ F2 G
" C2 ^* x8 g- }
验证python3及pip36 i/ u' s8 `7 A1 u3 Q, I
[root@centos7 Python-3.12.7]# python3 --version4 ~- i( T9 @9 j. w* Z6 ~- B
Python 3.12.7
" i: E: }$ F- T* D[root@centos7 Python-3.12.7]# pip3 --version$ X. [7 B# ^, z7 [
pip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12) W" G5 C" m; N5 g! a
3 I( ?7 l9 v+ A4 q) L; q# u
bash, s9 y5 y( _2 S+ i% \# r! t2 w' h
3 o& S! U1 m, u* f5 x# c0 [
6 }0 b# \/ w+ Q* Z; ^( C
^: R; h$ U% B% i( G( F9 v
3 b# z2 a i: A. B4 r4 T; K
1 O/ N; B$ z3 r' Q3 V7 V7 Q# b' a
" [+ u0 E5 I8 P% F1 T8 V7 j; u/ O
- a) W* B8 X7 g2 v3 {" g
|
|