- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
centos7.9安装python3.12版本
3 m& E% {9 r/ O& A, o6 b4 m& u. \/ T0 Q1 A2 S
Python 3.12要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上; e6 a2 U* b. [: s) t/ o4 ?$ Q
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz. J8 t1 u' q4 i# F) x: U8 T& t# ?
--2025-08-08 23:02:41-- https://www.openssl.org/source/openssl-1.1.1k.tar.gz! o' z$ U+ C- y: K
Resolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b:: q" Z3 \- i- I9 X' @; F$ `
Connecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.
1 a8 _4 P7 `/ j! r E: R% h0 _+ VHTTP request sent, awaiting response... 301 Moved Permanently9 C1 F6 g3 w; X% W% G \
Location: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]
1 e+ F% v# b ?6 `/ R$ w--2025-08-08 23:02:43-- https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz K. ~( J$ M4 r7 [. m' R
Resolving github.com (github.com)... 20.205.243.1665 ?* |5 A. j/ o
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
# N/ _% E4 Y+ o* mHTTP request sent, awaiting response... 302 Found' j: m @: Z& [8 w; J- |
Location: https://release-assets.githubuse ... tion%2Foctet-stream [following]( L0 E$ H& s, _( M
--2025-08-08 23:02:43-- https://release-assets.githubuse ... tion%2Foctet-stream4 Z) s9 U- N f- S7 v p
Resolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...; B- }9 {/ S; i6 }
Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected.
; U1 t: F6 U: K* ]* r6 X2 U2 GHTTP request sent, awaiting response... 200 OK
T/ P6 r2 L( ~, r0 j1 KLength: 9823400 (9.4M) [application/octet-stream]8 s ?2 Z: s' J
Saving to: ‘openssl-1.1.1k.tar.gz’
& T7 G$ G" Y* S- \" v5 X8 P) I$ o! L" g0 d( T! s
* `' |2 P4 g. e$ O5 u2 O) {$ w: ?1 R
100%[=====================================================================================================================================================================================================>] 9,823,400 203KB/s in 44s
. W7 l/ Z4 ?5 A m4 [1 m# X, p7 W3 q: m5 ?- V
+ P/ e" E0 @6 J( c3 M
2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]
# Z+ d( n4 p }3 y5 O/ y! L- [( W. e+ w5 M5 _) ~2 d0 k5 ~4 n, ~( Z
* e7 J2 P% q0 E1 ]& S8 l
备份文件:
" V8 T% a9 {1 b6 g1 T0 S. F% @0 s; s: r; A
# mv /usr/bin/openssl /usr/bin/openssl.bak
8 L. g- R1 _. D
6 L- s8 `0 v( H5 J9 M4 z! S v e& `! D
- n+ M* [! A" d3 {( Q, L
# mv /usr/include/openssl /usr/include/
/ j$ e# |% |3 v0 B6 x* h% k* B( _Display all 163 possibilities? (y or n)
3 s5 g( j' b+ u- N( e# mv /usr/include/openssl /usr/include//openssl.bak
0 ?* I9 t2 H2 U$ d( N$ o1 M
, {5 x3 G! A! m% q: M1 I4 l, Q. ?6 K2 T
解压openssl
7 k' ]9 Z/ a# {6 |+ f: N# tar -zxvf openssl-1.1.1k.tar.gz
: q0 Q2 @5 E" n( E! ]2 Q/ T2 K7 x: \* b/ G/ A
* R T7 Z9 v3 |+ N' Q
# cd openssl-1.1.1k/" m% V+ c0 i; A/ \; l
# mkdir build
) [8 J" J& V$ B7 U. T# cd build/ h; c, c n. i& p0 Z8 ]
# z' o/ D; D3 f- j. a" D
# ../config --prefix=/usr/local/openssl
4 S9 C, q/ ? `1 Y2 ]# g" b/ ]Operating system: x86_64-whatever-linux2
( b* G3 g5 l) A8 @9 y# [. `. r7 pConfiguring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64+ v# i# A- D. X1 N+ w4 q
Using os-specific seed configuration; c* X$ U/ J ~6 @ p
Creating configdata.pm; e' m3 \! g9 R: s0 V& C0 Y
Creating Makefile
! m4 g# R/ Z, t. s: W( C3 P3 X8 q9 ?( y% J, Z+ {
+ m6 X8 b, g9 s- X
**********************************************************************
. k( R0 [: A6 _*** ***
; g" V! ~. T. U0 n% l5 j1 f+ i*** OpenSSL has been successfully configured ***
" g6 T0 s- y9 r- C: ^- ~" ]9 t3 O*** *** U( D9 w: s' Z9 E0 Y
*** If you encounter a problem while building, please open an ***
# F1 w) U* G% p: h*** issue on GitHub <https://github.com/openssl/openssl/issues> ***3 A( x: D/ ?$ r8 R8 o
*** and include the output from the following command: ***. L) x: h" x' u5 E* z' V
*** ***
3 d0 f2 P- H# S5 \. n*** perl configdata.pm --dump ***
/ V! l9 w3 T8 k6 R3 Y2 v# a*** ***
* E1 Y$ M$ k- O9 ~*** (If you are new to OpenSSL, you might want to consult the ***) H; v8 C& I8 R: U+ T
*** 'Troubleshooting' section in the INSTALL file first) ***
$ a+ j. u# b9 y |0 f( @6 _& S; ?*** ***, H# j- {. a- y0 i
**********************************************************************
! b( w- X4 `% F0 \% H" T; | b4 k9 j# P
# make -j && make install3 P+ c2 p z2 }& z' Y: D# [
5 Y: Z# v3 D8 s D3 z9 [0 _4 C2 a
7 P/ K' D! @9 ?6 C" M做软连接:
# R e% I' J- L% @ ln -s /usr/local/openssl.1.1.1/bin/openssl /usr/bin/openssl
# [- u$ @, d1 o0 ` P: p# _1 ~1 y% l/ `& u/ x A8 L% u
# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
# a. I4 e+ \% D$ v# ldconfig -v: F8 C6 k4 R: `! }
ldconfig: Can't stat /libx32: No such file or directory
' A" _! W) M& N8 i' ^2 s0 Bldconfig: Path `/usr/lib' given more than once
! C+ H$ n& ?7 @ldconfig: Path `/usr/lib64' given more than once1 d/ F% R' w( J0 w
ldconfig: Can't stat /usr/libx32: No such file or directory+ B- O" Y! @: l `
/usr/lib64//bind9-export:/ r2 ?3 z1 _; P; y) F$ w$ ]; ~3 X
libisccfg-export.so.160 -> libisccfg-export.so.160.2.1" h7 B4 H- {) D0 B
, y' U+ k8 T8 f# openssl version5 k# o+ N: ?: a" W
OpenSSL 1.1.1k 25 Mar 2021
+ L- n0 H0 a: l
* g" B4 w+ T. R7 H$ l( {
) T0 X( C. S8 u接下来安装python3.12.10和pip3
, ^& E6 h& G! Y1 v- Z下载python3.12.7源代码; l9 I0 p) R( P* Z, {+ z$ E6 W
# tar -zxvf Python-3.12.10.tgz
! N) O5 r5 \- ^- G+ l1 d2 S7 m. ?/ G# I8 I1 [' O
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
0 v j: r0 j& K8 V8 b6 y
1 `2 y- }- A% z) v( J+ ]& k* z
9 X. D) W9 g% d( {6 X3 e* w5 }
[5 a" A$ K, i- L( |, C( u V4 Y
* j$ {+ J) A) }. T1 y) F) X7 N, G: F+ k9 v; o. k0 I
进入解压后的源代码目录
) @8 Y l }3 w5 L
% V6 X4 h- f' j( Z! W! {/ ~6 C l$ W# cd /usr/src/Python-3.12.10/# ?$ f* A4 ]2 X) a6 t, Q! v# ?
, W+ ]( S$ q C- u
+ t# F% y9 p. w+ k% _ _% l3 A9 m* c e: B; ^3 T* X
. H; q" e! F: a2 s; t9 o0 r配置5 m+ m: B$ [! U+ ^% g
# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl K( D! C6 x0 W- U" g c
@( R" d: I0 r+ ]; Y! z
% S+ W. \9 p- d' L: n编译
0 }$ _7 S' D2 I& u1 R6 R Emake% [7 _( D* W+ K8 b
安装
# K7 p: P! R1 c6 F) z! p1 R3 z" S2 Wmake install
6 x; V0 D/ X1 l7 A
1 o& S) q$ P/ ]0 L+ l& L! k: }& V, X6 m& L. ~
7 Q& h; i+ ]$ O+ |. g# H
# make && make install 6 n7 K9 P Z/ V4 t
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.c2 X2 W9 O Q8 @9 R/ [) L( E, M) _
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.c9 u3 T0 B* M3 d9 I u
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
H. e; f" i' J2 Y% 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/pegen_errors.o Parser/pegen_err
) |+ x r( C5 M5 [: F m
* ?; b1 g6 \1 A) K' T9 r3 A. r: I4 @0 b$ ^- O2 p# ~) E
. {6 p0 H/ ?9 T. S5 u创建软链接& g5 ^# P5 X3 G; k9 S2 M
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3* q& E4 i# R8 G3 R3 k9 [- {3 }7 _
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3% W- C9 p: o, y' E* l% d
8 {$ \+ \7 U8 A8 `4 U# o, K7 A$ h
0 W+ j2 b+ j& u% t$ B+ ]验证python3及pip33 \* |& u( _9 Q7 s, K
[root@centos7 Python-3.12.7]# python3 --version
1 @% w2 R/ H) I# VPython 3.12.7
8 T1 C$ u, O; M[root@centos7 Python-3.12.7]# pip3 --version: a! ~+ p9 g" W8 _; X; r7 _
pip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12)- y. `2 C2 `. k# _" T, F
+ P# Y# I2 r/ L
bash
6 |+ \( x7 [, ^7 L N! z0 e ~2 k1 Y3 `" z4 X: t
- Z* e* q2 }) N. b7 n7 `0 M
9 ^' y* h Z( l. A1 b! Z
) c2 f' C' C! Z2 \& g9 I0 _* ]5 B( n% k, ~
l8 N' S$ Z/ ]4 U% ~
6 `" W* }) H( F
1 G' q2 A* h/ U7 U6 F* V8 } |
|