|
|
centos7.9安装python3.10版本; A( O* p4 ? a' G. h+ n
先下载python3.10版本
+ G2 ]+ n; [5 J, E0 u2 @- `( P, g1 Z0 Q* ]' c8 u
Python 3.10要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上
$ v6 |6 ?" e3 Y: @2 U* ]0 Bwget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
/ ~; e! i4 Q; H4 H--2025-08-08 23:02:41-- https://www.openssl.org/source/openssl-1.1.1k.tar.gz
|$ ^ s5 ~2 e: t3 rResolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b::
2 X4 k3 L$ W2 j! [& UConnecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.0 v* A% }. Y( M r
HTTP request sent, awaiting response... 301 Moved Permanently8 ^. ~# M( i! X, h5 v2 l; o- a2 @% }
Location: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]$ t0 O! {4 U6 |$ L( \) [8 p
--2025-08-08 23:02:43-- https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz1 {: C9 W' i9 l2 i! J2 p% R
Resolving github.com (github.com)... 20.205.243.166( O, Y; ?, e. T
Connecting to github.com (github.com)|20.205.243.166|:443... connected.+ v* |6 B' B$ O, U z* U4 }
HTTP request sent, awaiting response... 302 Found& M$ I0 t- \2 ?% _9 e3 ]- i
Location: https://release-assets.githubuse ... tion%2Foctet-stream [following]* s& v; s0 {- B
--2025-08-08 23:02:43-- https://release-assets.githubuse ... tion%2Foctet-stream
$ t5 C8 k2 `; s* q! D. cResolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...
& a4 i9 u9 S3 o3 \5 G; oConnecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected. C( s4 Y! S! n' w- Q6 C
HTTP request sent, awaiting response... 200 OK
$ A6 V4 y. f7 y) yLength: 9823400 (9.4M) [application/octet-stream]' u/ h2 h: K% a0 Y# J: c9 x$ X
Saving to: ‘openssl-1.1.1k.tar.gz’7 l0 T+ z7 L, v% [
* \- x/ j& Z2 s3 ] W2 u' R7 Y9 f
: L1 l6 B7 H4 s7 T
100%[=====================================================================================================================================================================================================>] 9,823,400 203KB/s in 44s 1 \9 E8 p0 a% ]& I
! \4 y. s/ X) N7 G. p( l9 U# C3 |+ U" Y: N
2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]
& C" y1 d4 i) p0 g$ T, G5 ^! ^) }: q) P
4 A) P' x" r7 j5 T备份文件:
& ]% |4 ]* U% C' S1 R
" t2 g" S# }3 n! y+ Y1 D" w# mv /usr/bin/openssl /usr/bin/openssl.bak
+ `, L# q0 ]# L5 e3 \- l4 B! K) a$ R
/ |, e3 M o! L0 C
* L$ z; g2 r6 {, w$ e- G+ b+ Q
# mv /usr/include/openssl /usr/include/
. k; w3 M1 B' T! [% ]Display all 163 possibilities? (y or n)( H/ ~. _ Z- I& `- a x; e
# mv /usr/include/openssl /usr/include//openssl.bak+ ~4 J, X6 Z7 u5 n* F
( _% X0 c3 r, F D
' ]% U$ H, G6 W
解压openssl
6 Z# o) c0 ~' e& c& ^# tar -zxvf openssl-1.1.1k.tar.gz( M* l" U; |1 X" x' G& [2 C
3 E# U0 H8 r! }6 J( _. I
2 l- h' ^+ g2 ]/ Q& V2 ], t
# cd openssl-1.1.1k/
S1 s- z0 l) ?" m# mkdir build
! R, t1 M6 P% ]5 F0 o# cd build/
# S9 D' X/ M) v, M7 R: b ]* e
* i$ B. V$ x$ P, w# ../config --prefix=/usr/local/openssl
0 v9 |6 V( {4 e g1 kOperating system: x86_64-whatever-linux25 t, T2 m& r- H7 Y4 c6 Z! f- I! ?
Configuring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64+ f+ Q) T5 g0 ]+ B# ?9 a
Using os-specific seed configuration; e* E$ H U( z0 p# S0 i; Q
Creating configdata.pm9 W7 o8 v% a' W' W& Q5 N+ a
Creating Makefile: k2 G9 X* ~, D" |
+ E; n% ^& N# l: s( B1 g( [' E9 [ i% v" M7 @& L; d; U& Z7 p
**********************************************************************
0 c3 a8 E6 |8 I( t*** ***
+ X. }: @" a! Y5 F*** OpenSSL has been successfully configured ***
) v5 {) M& L* B*** ***
+ X' Z4 p9 Z9 z6 Y2 U*** If you encounter a problem while building, please open an ***
. H" `- J. }$ u5 c*** issue on GitHub <https://github.com/openssl/openssl/issues> *** d3 n) V X, }! ?
*** and include the output from the following command: ***
" X& o R1 m J2 @- H*** ***: Q. b2 h6 b% k3 A, k! Q
*** perl configdata.pm --dump ***
, M+ z. d* A3 h/ e3 P( }*** ***% ?, @; K4 U( E- S
*** (If you are new to OpenSSL, you might want to consult the ***
; z# d9 F- K! k& D& |7 K*** 'Troubleshooting' section in the INSTALL file first) ***" g" N) \- V; y |. v
*** *** i2 J( [/ j5 ?& q
**********************************************************************
5 E8 C0 k F. w: M- P3 k) D9 @# X7 q: }2 e
# make -j && make install
9 G7 w: ?' A# x! F7 B1 h- b" i& A4 r x8 Y7 F/ V6 ^6 Z
& O: P* ~4 m! K: Z' i# b& {3 n# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
/ B3 s y( K9 M7 {/ j# o" b! J# ldconfig -v+ V- N' S I) K9 g$ k, Z
ldconfig: Can't stat /libx32: No such file or directory
, A, V8 x1 ]0 j$ hldconfig: Path `/usr/lib' given more than once
+ G0 C8 K% a" I. W- C8 T) c) Rldconfig: Path `/usr/lib64' given more than once
: \ _& l0 A5 ~6 { j; Zldconfig: Can't stat /usr/libx32: No such file or directory
6 M$ a: h/ t; ?/usr/lib64//bind9-export:
' j4 k, e% M6 e5 Z0 A, L: m libisccfg-export.so.160 -> libisccfg-export.so.160.2.1/ J3 a- V# v$ H; }6 h3 t
4 u4 g9 Y. m- a S6 h
# openssl version6 ]$ A8 a6 @. a0 H; R3 j4 `" ]
OpenSSL 1.1.1k 25 Mar 2021. m$ d/ R8 ~9 V+ U2 w
: g/ `. q& D5 r9 z8 V9 R5 f
; Z }+ }, j9 ~0 a5 }9 P/ ~) v
接下来安装python3.12.10和pip3
5 [+ q7 ~6 m U& {+ l; w) u下载python3.12.7源代码; X) X1 Y; z4 G% T
# tar -zxvf Python-3.12.10.tgz
" H/ ]9 J- z1 q3 I) K4 T9 v" y, w. j6 b8 [4 @& T6 l; U0 ?
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
/ j5 I8 y O# P2 ~ c8 Y
1 `, ~/ C+ z! n+ w! P2 y/ M a' g; Q; g0 G( q, v
4 r0 m. D0 |4 }/ i% a* o
+ p: T( h7 v$ j. e8 u
7 a3 w6 ?- F* A% f+ t进入解压后的源代码目录! l; N n; Q6 U W8 x) j
- H% [2 @7 _6 p# cd /usr/src/Python-3.12.10/
& d$ O* l- G2 p; X' O5 b; b2 g! a# k, @
$ u( x5 F- B u* x1 d
. |) d, Z# K- N8 z- l" ~9 f! w
/ G- @4 d- U+ g) \4 q
配置
1 S& Z& n! H8 U/ g8 G) B) _# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl# J0 D3 j2 p; o# ]* G
% z# T1 v/ F* r C& ]( n7 Y. I7 t" |/ k
编译' X4 d' L6 ^4 m1 V
make
5 y- s) ~1 G/ G" p安装
' h: |) f: k( b. _& Pmake install
- E* w0 p2 Y( H) g) U9 l1 y
; }* G; c/ K% L' E
- [! D$ k, u: x& M. Q
- @9 h( X* k1 C( ?8 ?. M* w, d# make && make install
; o: R: W3 ?; q/ I6 ^& pgcc -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
$ T0 N- r2 H5 X3 t4 \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
# F0 D) u4 t3 X; ?' Ygcc -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
) Q% T) u: b0 T( C9 N- V, `! Wgcc -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+ [3 y! C* B+ s; \4 h1 W r
0 N1 M9 N# c* d
+ _' A* e. P; x w; h! W( o8 a
/ h: q0 S' t: n" V1 S% X创建软链接& v9 z6 L/ K. C
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3
# J2 Y; E- U; J2 r+ c a" h: Pln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3
% I% j% \, G9 j5 a9 o0 G; R+ \) h0 k
' w7 [9 h3 f. g
验证python3及pip3. t4 `7 \. C- d1 x5 w
[root@centos7 Python-3.12.7]# python3 --version8 z- g5 C, e9 n. B( W; Q
Python 3.12.7# V S: |1 O* U U
[root@centos7 Python-3.12.7]# pip3 --version! d4 k1 f2 K. [& f2 x* K
pip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12)8 C. @6 a$ F2 A! S, c0 b
/ S e5 j+ z/ ?" j
bash
. U) c' R' {% b2 ^3 N! t8 J' N0 c1 Q9 u! F& K. E$ c( ~1 a, |
( T- v1 m5 m& L* n Z |
|