Linux手工安装官方Python3.5

youandme 2020-06-03

1.安装相关依赖库(工具包)

yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y

2.下载python3的源代码(在linux终端下输入命令)

切换/opt目录

cd /opt

#下载python3.5.6源代码

wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tgz

#python源码的下载地址。(全都在这了)

https://www.python.org/ftp/python/

3.解压缩源代码

tar -xf Python-3.5.6.tgz

(出现Python-3.5.6)

4.切换python3.5的源代码目录

cd Python-3.5.6

5.生成编译脚本(指定安装目录)

./configure --prefix=/opt/python35

6.编译

make

7.编译成功后,编译安装

make install

8.切换已经装好的python3.5目录

cd /opt/python35/

9.查看python3.5的可执行脚本文件

[ python35]# ls bin/

10.执行python3.5解释器

1.绝对路径执行方式一

/opt/python35/bin/python3.5

2.相对路径执行方式二

[ python35]# bin/python3.5

3.添加环境变量

1.添加软连接(用法)

ln -s 原文件路径 目标文件路径

2.添加软连接

(绝对路径)ln -s /opt/python35/bin/python3.5 /usr/local/bin/python3

4.添加pip3软连接

ln -s /opt/python35/bin/pip3 /usr/local/bin/pip3

5.查看pip3版本

pip3 -V

pip 10.0.1 from /opt/python35/lib/python3.5/site-packages/pip (python 3.5)

tip:

python3.5软连接:

ln -s /opt/python35/bin/python3.5 /usr/local/bin/python3.5

删除python3.5的软连接:

rm -rf /usr/local/bin/python3

相关推荐