apt-get update
apt-get install wget
wget https://www.python.org/ftp/python/3.6.7/Python-3.6.7rc1.tgz
其他版本https://www.python.org/downloads/source/
tar -zxvf Python-3.6.7rc1.tgz
mkdir -p /usr/local/python3
cp -r Python-3.6.7rc1 /usr/local/python3
cd /usr/local/python3
cd Python-3.6.7rc1
apt-get install build-essential
./configure --prefix=/usr/local/python3
apt-get install build-essential这一步是必须的,参考:
https://askubuntu.com/questions/237576/no-acceptable-c-compiler-found-in-path
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
vim ~/.bash_profile
按i开始编辑,复制入以下内容
# .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 -V
如果看到打印出版本号,说明安装成功了
网友评论