liunx下安装python

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38934189/article/details/79131190

1.下载python3

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

2.安装python 

安装路径(看个人喜好,路径随意):

mkdir -p /usr/local/python3
解压下载好的压缩包,我这里是3.6的包,按个人下载的解压:
# tar -zxvf Python-3.6.1.tgz

3.进入解压的目录,进行编译安装
# cd Python-3.6.1
# ./configure --prefix=/usr/local/python3

make

make install
4.建立python3的软链
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
5.并将/usr/local/python3/bin加入PATH
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
按ESC,输入:wq回车退出。

修改完记得执行下面的命令,让上一步的修改生效

# source ~/.bash_profile

检查python3及pip3是否正常可用:
# python3 -V
Python 3.6.1
# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)





猜你喜欢

转载自blog.csdn.net/qq_38934189/article/details/79131190