以下是编译安装方式:皆是绝对路径,直接粘贴即用
经验总结安装python3的各种依赖包,一定要先安装依赖包!!!否则每次安装python都会报错少了某个依赖包,安装依赖包之后又要重新编译,如此下去循环,会崩溃的·····
yum install gcc zlib zlib-devel libffi-devel readline readline-devel openssl openssl-devel
注释:
- gcc:编译依赖
- readline:解决python命令行中删除键无效的问题
- openssl:解决pip3安装python包报错的问题:下面是对应的报错信息
pip3 is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
下载python:
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
安装:
解压:
tar -xvf Python-3.5.0.tgz # 解压到当前目录
进入解压目录,测试安装平台:
./configure --prefix=/usr/local/python3.5
编译并安装:
make && make install
检验是否成功:
/usr/local/python3.5/bin/python3 # 回车进入python3.5命令行
创建python3软链接:
ln -s /usr/local/python3.5/bin/python3 /usr/bin/python3
创建pip软链接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
测试命令 python3 和 pip3
python3
pip3