Python 基础:python 安装-Linux源码安装
概述踩过的坑:
一、安装前准备二、安装过程1. 安装依赖环境2. 解压源码包3. 查看安装说明4. 编译并安装5. 验证安装,并添加环境变量
概述
本次在CentOS 7 下完成源码安装,并实现python 多版本共存。
[root@localhost ~
]
CentOS Linux release 7.6.1810
(Core
)
踩过的坑:
Error1 Could not build the ssl module! Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host(). 解决办法:
源码编译安装指定的OpenSSL版本
Error2 zipimport.ZipImportError: can’t decompress data; zlib not available make: *** [install] Error 1 解决办法:
[root@localhost Python-3.7.5
]
一、安装前准备
软件名称软件版本备注
Python-3.7.5.tgzlinux x64下载zlib-develzlib开发工具镜像源YUM安装即可gcc、gcc-g++C编译器镜像源YUM安装即可make编译工具镜像源YUM安装即可
二、安装过程
1. 安装依赖环境
[root@localhost Python-3.7.5
]
2. 解压源码包
[root@localhost Python-3.7.5
]
[root@localhost Python-3.7.5
]
3. 查看安装说明
[root@localhost Python-3.7.5]# more README.rst
#预编译安装到指定安装目录
[root@localhost Python-3.7.5
]
--prefix
=/opt/python-3.7.5
--enable-optimizations
4. 编译并安装
[root@localhost Python-3.7.5
]
[root@localhost Python-3.7.5
]
[root@localhost Python-3.7.5
]
5. 验证安装,并添加环境变量
[root@localhost Python-3.7.5
]
[root@localhost Python-3.7.5
]
[root@localhost Python-3.7.5
]
[root@localhost Python-3.7.5
]
export PYTHON3_HOME
=/opt/python-3.7.5
PATH
=$PATH:$PYTHON3_HOME/bin
export PATH
[root@localhost Python-3.7.5
]
[root@localhost
~]
Python
3.7.5 (default
, Oct
31 2019, 21:23:03)
[GCC
4.8.5 20150623 (Red Hat
4.8.5-36)] on linux
Type
"help", "copyright", "credits" or "license" for more information
.
>>>
总结: 其中make test 时间相对较长,只要出现的fail 不是很多,就没啥问题。仅此保留安装过程,分享下。
相应参考链接: Python 官网 Pypi Package官网