找回密码
 注册
查看: 317|回复: 0

centos7.9安装python3.10版本

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2025-8-9 10:55:48 | 显示全部楼层 |阅读模式
centos7.9安装python3.10版本% E& _' k" F2 ]; t" I  A
先下载python3.10版本
7 c2 w3 r2 n; S+ B' m$ e8 A+ ]  x6 [3 @; M
Python 3.10要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上
2 c, {) m6 |7 P7 J- z0 Hwget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
, ~* J0 m3 `; e5 T2 M8 v- B$ D% B  n" Q--2025-08-08 23:02:41--  https://www.openssl.org/source/openssl-1.1.1k.tar.gz
4 t' f% I* f% Q* gResolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b::! Q# \5 u/ Z, I/ |& M" u0 m" _% m
Connecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.
! k4 F! r$ J6 UHTTP request sent, awaiting response... 301 Moved Permanently. |8 i5 x" \/ h/ h4 i1 Z1 n
Location: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]6 m8 y3 t0 h, h$ `
--2025-08-08 23:02:43--  https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz
, N7 J- o! H$ ~  i6 g9 w+ nResolving github.com (github.com)... 20.205.243.166
3 v8 H) T$ r% A9 K; l6 d$ |Connecting to github.com (github.com)|20.205.243.166|:443... connected.: j1 Z5 R2 [6 J( v2 C5 w; U! m
HTTP request sent, awaiting response... 302 Found
0 c! P9 ]  \% T* B4 o) B! kLocation: https://release-assets.githubuse ... tion%2Foctet-stream [following]. |6 |" z2 `3 c' Y8 t7 ~
--2025-08-08 23:02:43--  https://release-assets.githubuse ... tion%2Foctet-stream1 B. |) ^1 I0 ?2 t1 H
Resolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...* ^2 A+ w9 b2 E5 @/ J0 D9 F
Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected.
" V& M+ w- v3 U: z# uHTTP request sent, awaiting response... 200 OK
* `  W: R6 ^; _( n0 O2 _+ wLength: 9823400 (9.4M) [application/octet-stream]; a" D: ]. |8 V; }1 v# Q
Saving to: ‘openssl-1.1.1k.tar.gz’& C* R! Q- p+ T  V- S, n$ d

3 H9 k# `, `! @$ ^; s

! g3 ^8 M& w7 F8 E7 S1 e$ s' ^100%[=====================================================================================================================================================================================================>] 9,823,400    203KB/s   in 44s   
  Y- `& ~# @( ~0 @1 ~: \& x/ d  \# p" v

) Q+ x& H0 M& o# I2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]4 U: R: N' s# L  }6 p
1 {+ t& k  W; U  t' u9 V- ]
$ M8 C) P8 p# m8 {) W% R% _
备份文件:+ B7 v* G" z5 W! n3 i9 m, ?

1 {4 y/ t. b0 t: L# mv /usr/bin/openssl /usr/bin/openssl.bak7 K  @; [! a6 A$ J
( q" o" S6 o$ f! [% f+ u' F
' T' d9 r" r% r1 m

- l, c9 c& s# U7 d$ N1 f! w9 N; ]# mv /usr/include/openssl /usr/include/
' e' ^/ |; S9 s- F) l$ ADisplay all 163 possibilities? (y or n)5 z( @" ~  a# j6 {* E2 h
# mv /usr/include/openssl /usr/include//openssl.bak/ G" g% s7 [3 _  R/ e1 f

6 {. a! U5 l  Q' F  p

8 _) s; ~% Z, X1 A解压openssl
1 t, x0 L8 J0 h7 ~. G6 m; n% H# tar -zxvf openssl-1.1.1k.tar.gz
3 J9 b9 f  M7 S6 R: r: w- H% Q! [( T" G% P1 [
& E  j$ ^' X2 r9 {
# cd openssl-1.1.1k/
& H$ W3 y: Z5 \9 r8 s# mkdir build1 ^% m4 Y4 a+ p& X$ ]) ]
# cd build/" T/ r  P3 k* C4 {( a3 j3 F2 |9 k

4 p' b! r( |) }$ [8 v: Z0 |2 z" l0 ^# ../config --prefix=/usr/local/openssl
6 H& D, g* m- T  A: x* ZOperating system: x86_64-whatever-linux2# O$ c0 X1 I9 {+ l
Configuring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64
8 d5 i3 n9 d9 f2 r7 eUsing os-specific seed configuration6 y1 B7 U8 B7 L6 a' }- @! H
Creating configdata.pm
2 A/ |' w5 f( E2 K: I! VCreating Makefile( M( J5 u- q0 J: B' J0 s. ?

/ |) }& w& |4 ?4 U* }1 @4 [
7 {/ S$ A5 w! T8 E
**********************************************************************
, K; t7 }6 k, J***                                                                ***
$ \0 V4 R( X. j( n0 i+ }***   OpenSSL has been successfully configured                     ***
& s) q- W. @' t0 O, I! z4 |) X***                                                                ***: ^- l- |% w' R! C
***   If you encounter a problem while building, please open an    ***
7 g! z- v4 A- h2 t4 ]***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***# v3 h- K$ U$ s. [  H0 |
***   and include the output from the following command:           ***/ O/ N# J# X8 x5 v5 V
***                                                                ***
: @& c* F8 [+ f2 N% S  r8 T% d- T3 F***       perl configdata.pm --dump                                ***
+ M% K+ Q# l! r6 Q2 B5 s% [6 Q***                                                                ***
$ e2 l. D; }) r1 Y***   (If you are new to OpenSSL, you might want to consult the    ***
- V( f3 a/ b3 ?' p8 ~) O9 E***   'Troubleshooting' section in the INSTALL file first)         ***
! u) V& ?5 C" f0 ~! ?) o: j***                                                                ***% @: m+ ]- [. f2 z6 \$ F
**********************************************************************! p- d1 V6 I) b
7 D+ C5 j& K) q$ P4 q3 @
# make -j && make install6 Y4 h1 N+ r2 J" x

& c* t0 |( q* i8 {2 o& {+ F
0 {+ j7 N. D# @8 x
# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf- z4 Z! e& N6 o8 @2 h" @4 z+ R# C' \; L
# ldconfig -v1 W" H0 c3 g* O" t  |
ldconfig: Can't stat /libx32: No such file or directory
& g7 ?0 H6 a! |; J9 b- e! w0 J- m4 Fldconfig: Path `/usr/lib' given more than once) D: K; F, f7 m& j0 c. Y
ldconfig: Path `/usr/lib64' given more than once! R; F& T1 H# U( o: }
ldconfig: Can't stat /usr/libx32: No such file or directory/ T1 d9 v( ?) \* D/ q. @0 ]- O
/usr/lib64//bind9-export:
; B0 A5 ?/ D) C0 {- b2 V( G0 I        libisccfg-export.so.160 -> libisccfg-export.so.160.2.1
; ]1 K  h/ ]6 e
, ?- l: l: r) M6 U/ J, ~# openssl version8 K2 C" x' V6 b! E5 K
OpenSSL 1.1.1k  25 Mar 2021
3 k5 g3 u9 Z9 o1 b$ z& w# p% d
# q6 Q  d/ J* k9 w0 [+ p% I% J* B& X8 s( `% i5 P5 J5 e
接下来安装python3.12.10和pip3, q) i. C3 S/ o  ^; ^! \
下载python3.12.7源代码
3 {. a9 s! i7 `9 c7 v# tar -zxvf Python-3.12.10.tgz
. F9 ~. O2 p7 C! s. ?; k2 B' Q* o0 T; u2 H' d! d8 S
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
* D% c" Z/ B' _1 L" N' d5 ~# s: O# v4 `" \

; a  l+ \7 j- |. ?, c; |1 a% z: z. u% T( E9 {$ A. T# V

3 O- Y( [+ n2 }" q) J# s$ }

) C/ R* B# Y7 d$ `2 Q- \2 ?4 L6 M5 `进入解压后的源代码目录* h6 ~* \4 c. {% w* g! _6 ^
2 W) c8 N: J' v9 b3 n! U
# cd /usr/src/Python-3.12.10/
, d( L# ~7 k, d# h) Z( o# {* d: f; M& s

, T' y; j+ {5 t, |* n! i$ s2 V
& c! h' i4 L' \6 }3 ~) N

8 B( L" u* Q" n# C7 b( H( ]! _配置" {5 F- }! s8 \" T: z' Z
# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl/ M" }2 w" G9 a" m$ U

& P% P7 G' D1 j3 h$ ^8 r' q

5 h4 ~' x  O) K0 b1 B0 C编译: R" |( [/ l: u0 D- _: e1 {
make
: U6 D+ _1 C0 l" R, `7 ?安装
* S' u. V$ Z6 hmake install
' }. b! p' ?3 W- h
2 Y4 ?; r: }  k: t

2 l) J" _2 g  f' ^) }- N3 r2 }$ B6 E' O$ e. y
# make && make install
. ]% d; v4 P8 G: Z; {7 K( f# 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 Programs/python.o ./Programs/python.c
8 b2 L  c" k  w6 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
* ?. P- Q- U+ y9 T- Tgcc -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
; O0 }% W0 M* y# C8 e- Cgcc -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% L. S) q+ K  J; y2 f+ C5 O* z
& j2 @! `& D' a4 S, x: t, L  |
. W" x. o+ Q9 k9 U' X
$ R; b2 d* ~0 O* _1 }9 w! {7 e
创建软链接  P4 c( G: t- A9 m" D) M' f
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3
# L+ T+ e5 S. mln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3
6 v( B- w# b- R. s, {
. G5 {2 R# I: T* P' \& D

1 R. f3 m; [9 R验证python3及pip3; P1 D- o, Z- x" U& q& u, x
[root@centos7 Python-3.12.7]# python3 --version' X# D" R5 q) D# t! B" Z
Python 3.12.7
9 v$ w! S- I6 }6 ~+ o[root@centos7 Python-3.12.7]# pip3 --version
$ c( N- n" ]9 \  a/ \pip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12)
+ d5 C3 }$ s3 N" L6 A3 C" F% f' I# g' v- ~
bash
/ ?" G8 @0 p0 B+ k8 [) X8 t5 Q1 h
' ~" I% b4 @$ e* s) `4 K& I- c

  s* j! m1 f: R/ _
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:48 , Processed in 0.016626 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表