- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
centos7.9安装python3.10版本4 e+ u- c; a, U3 u/ A
先下载python3.10版本
# O$ p! u% y. a' g0 C3 K4 g5 A9 P& l% u* b8 P
Python 3.10要求的openssl最低版本为1.1.1,环境中自带的1.0.2k无法使用,所以需要先升级openssl版本至1.1.1以上- w b) I* m. N D' F) P5 f6 @
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
; p9 ?: u. U; |) w/ S--2025-08-08 23:02:41-- https://www.openssl.org/source/openssl-1.1.1k.tar.gz
7 W! J7 Q: z$ V3 d. X6 _; OResolving www.openssl.org (www.openssl.org)... 34.49.79.89, 2600:1901:0:d50b::$ F# z3 j3 F# a% n2 s6 [9 M- b
Connecting to www.openssl.org (www.openssl.org)|34.49.79.89|:443... connected.) X. H8 D+ f( S Q
HTTP request sent, awaiting response... 301 Moved Permanently
/ D# p$ ~3 n4 s5 WLocation: https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz [following]7 f- ~6 |0 h* R5 U
--2025-08-08 23:02:43-- https://github.com/openssl/opens ... enssl-1.1.1k.tar.gz
4 ]+ _' k& w# e/ i) N7 lResolving github.com (github.com)... 20.205.243.166! J Q# G( u. ]
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
5 u H1 h" Z0 H4 LHTTP request sent, awaiting response... 302 Found
* @) Z( C+ d! V3 MLocation: https://release-assets.githubuse ... tion%2Foctet-stream [following]3 d b5 U! }+ N0 L
--2025-08-08 23:02:43-- https://release-assets.githubuse ... tion%2Foctet-stream: v E1 ^( C+ v$ {
Resolving release-assets.githubusercontent.com (release-assets.githubusercontent.com)... 185.199.109.133, 185.199.111.133, 185.199.108.133, ...8 o) j: |9 m9 L, }6 W! }2 } E
Connecting to release-assets.githubusercontent.com (release-assets.githubusercontent.com)|185.199.109.133|:443... connected. ^/ s) l4 [ ?/ j, i
HTTP request sent, awaiting response... 200 OK% Z" [! v7 @& ~3 V. e7 j! o
Length: 9823400 (9.4M) [application/octet-stream]/ F" J( x/ h \1 `, p. X
Saving to: ‘openssl-1.1.1k.tar.gz’" X3 ~. D0 P4 K+ s& d
$ p: R9 u4 G+ I L+ e1 w
5 }) k' V7 _3 I100%[=====================================================================================================================================================================================================>] 9,823,400 203KB/s in 44s
4 }4 l4 Z+ i7 a* }1 a) T1 Z
( _$ y3 _+ m3 C% ^* b- c: \& y! B D! |
2025-08-08 23:03:28 (218 KB/s) - ‘openssl-1.1.1k.tar.gz’ saved [9823400/9823400]5 n' K6 H; N/ A' C/ e
& Q: I: w0 y' K- D
0 ~% ~3 f M; ^3 X- [3 g# L备份文件:% i2 `3 K0 s+ V" O; \( t
$ G5 Y6 @2 q8 [0 x3 I8 A# mv /usr/bin/openssl /usr/bin/openssl.bak5 l+ c2 w' T: h# m# N+ C1 n, `4 H7 I
8 d5 o+ g; Y" R+ F+ s4 c3 H( v+ f
: k1 E1 C* n8 X0 B" g- x
. D# R' ?. l* g$ v
# mv /usr/include/openssl /usr/include/
7 d( t' D5 u) UDisplay all 163 possibilities? (y or n)
. ]( b1 R% g. @0 B' M: Z" Q# z* G# mv /usr/include/openssl /usr/include//openssl.bak4 A3 Y: R5 \, z% B2 z1 I; P
: M6 a7 i" s, t0 e& q4 Y9 u
* I H J( Z$ Z5 u V8 A& U x解压openssl
9 b! O8 |8 Q: W8 B1 {# tar -zxvf openssl-1.1.1k.tar.gz
# N4 W+ i5 n4 T8 p/ L5 \. E' X2 R2 f) y7 V# z
' S, G2 t" o* H5 a; T5 B# cd openssl-1.1.1k/$ [$ T' B+ K7 C1 x( ^# A, M
# mkdir build
4 O# W3 j1 R5 D. T# cd build/
3 r8 F7 g0 C0 Z, N" K: L$ K6 c/ F1 ` q
# ../config --prefix=/usr/local/openssl
5 B+ V# ^3 X. W3 L0 g5 S. x$ eOperating system: x86_64-whatever-linux2
6 F) u) t& j I; i9 l. hConfiguring OpenSSL version 1.1.1k (0x101010bfL) for linux-x86_64
: d! d4 Z$ J- D" a1 z( P: mUsing os-specific seed configuration) R* s0 k& v& x8 ?9 }$ {
Creating configdata.pm
' p& {# Y' W; [. {Creating Makefile% \ p. l+ V" q$ m8 L! w
$ n% s4 x: p- ^7 o- F
6 E% B) z- {4 E. Y0 X" Z" v3 z**********************************************************************- Y y m0 o. @) h
*** ***
0 t/ Z5 t& c( I& I/ ?2 \*** OpenSSL has been successfully configured ***
" W8 q: X+ V' D+ g% W* n+ Z*** ***4 w% A4 R0 I: k2 }, T% ]) J
*** If you encounter a problem while building, please open an ***! \& u& k" v9 d9 Z, u
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
/ ^0 q7 o* H3 w/ q& g*** and include the output from the following command: ***! t8 H2 q. p- L
*** ***9 ~* B" S- ]$ {9 q6 k8 `
*** perl configdata.pm --dump ***
4 W) S9 K) y6 K% F6 |2 M*** ***
$ T9 x) |8 q- H*** (If you are new to OpenSSL, you might want to consult the ***# I, S. k/ L6 Z- I
*** 'Troubleshooting' section in the INSTALL file first) ***. k0 V% W$ w, c6 g" G) i
*** ***
) ?; t/ P8 K" y# k. `7 l& p6 W**********************************************************************
7 Z" V5 x( _. K' E
9 ]4 J' b7 k4 G# e- j# make -j && make install
) X- p1 ]2 g: e5 c% t! d+ Z6 d4 F
; }( I$ T# S& W0 F7 k7 {
* P. J- Y, w* R) I ?, h# echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf0 o7 E; m6 t" \9 R
# ldconfig -v
/ O7 S' h( M* j/ {ldconfig: Can't stat /libx32: No such file or directory. {0 l1 B9 x$ Z! N2 ?+ O: K6 p
ldconfig: Path `/usr/lib' given more than once% Y! F9 r; o( I/ h3 w' r
ldconfig: Path `/usr/lib64' given more than once1 v5 o7 Y- u% I3 a$ d0 s) v
ldconfig: Can't stat /usr/libx32: No such file or directory) t3 Q, Y' d9 | D4 s5 L2 X% z
/usr/lib64//bind9-export:& ^$ f+ `; R" V4 i
libisccfg-export.so.160 -> libisccfg-export.so.160.2.1
. |1 s4 `1 S$ l$ ]; z, M
+ a7 t1 w2 @/ t( [8 L0 v; }# openssl version& W7 @5 s$ v1 a& ^" \. }( ^
OpenSSL 1.1.1k 25 Mar 2021
' R# `- }( R9 |0 X8 l4 N& n0 @1 r: G( G$ s5 Q
% V1 z8 t! j, n2 i3 O+ ] \. w接下来安装python3.12.10和pip3& w4 c! u: R" y4 G% `1 i2 K
下载python3.12.7源代码' N8 I6 W7 i7 q. W g
# tar -zxvf Python-3.12.10.tgz& y4 F6 N$ a0 E, e7 P( I. j- `
+ H5 O; H% K# L! }4 @* G
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
! T0 b. E+ m% @; m4 L! V5 @6 w
, k. O2 N. q1 z1 P! \$ B+ o( K* B
& }7 j. X- A! C$ q. g: r* Q
0 x' k+ U& t6 x2 l# r# S( d
% Z; F1 Z& a* s; A0 C5 j0 u- ]
% ?" H4 |5 r1 c进入解压后的源代码目录
' E# h) k+ }! w8 [) T
" Z A4 z( j8 d4 W# cd /usr/src/Python-3.12.10/: m. t* e0 G7 T" {
! c0 r* N3 q; A1 I; y: r3 T. p
! O9 X$ q i3 E1 J4 f0 z4 F
# m4 a6 H0 [3 _4 G$ f3 Z5 z, R* |* X6 J$ J6 g g; C3 H
配置* L$ U* [/ y$ U7 q- ?" o
# ./configure --prefix=/usr/local/python-3.12.10 --with-openssl=/usr/local/openssl' `* }$ o) k' }5 ~$ ]+ q; R5 a& i* H" ?
! k: Z; |- I* {" w
& y5 `) a5 \" r8 [; i
编译
]* Y3 U+ y/ { ?0 F3 b! \make
. o% I/ Z* R; z2 j8 {+ r7 f3 f安装
1 X8 n# Q& t; I, e0 w6 \! ]make install
/ I1 r) T& {6 _0 l& g% w" o) ], I; `2 ?: d
9 W) `" i& n, } X4 `9 a' r
: v7 _& P7 I0 g3 w8 w# make && make install" c6 u) p# h) ]8 R3 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 Programs/python.o ./Programs/python.c
- v& J, g {1 G' d/ |, `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
, ?$ V4 {! T. z% A# }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$ {3 x, O! s' Z% L. T1 N7 a
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_errors.o Parser/pegen_err3 n. b* t1 ^# @# q/ _8 Y
3 Z( J& c: L3 R; o y2 K. l: W& D7 u5 Z
: c0 U) q7 P% g# O
创建软链接" y8 P" v0 a0 X% Z
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/python3.12 /usr/bin/python3! R" T* ?0 W- v! [) j% ?, J7 x
ln -s /usr/src/Python-3.12.7/Python-3.12.7/bin/pip3 /usr/bin/pip3) {/ O, n. u' g% B$ s& }9 T. |
4 E& r! k2 c1 O4 l6 B& J
( K( q P+ A/ u0 O验证python3及pip3) W$ Q, b8 z, O4 c5 C+ N9 N
[root@centos7 Python-3.12.7]# python3 --version$ G* n% _$ q( |# G9 ?' V
Python 3.12.7. B9 `8 V; r& ~5 H
[root@centos7 Python-3.12.7]# pip3 --version+ _% _9 g, ?8 e G6 D5 U
pip 24.2 from /usr/src/Python-3.12.7/Python-3.12.7/lib/python3.12/site-packages/pip (python 3.12)
8 u5 n4 R. u+ Y6 U* H$ @$ B
$ b, F" w, n2 ?' Kbash, D( c; r$ a5 L% k6 X
: h( q2 M1 @+ a# a. v& A, B
: O4 w/ o# i8 m8 D7 N; J/ {+ K |
|