文 / 秦未
演示系统:Ubuntu16.4 ; Python版本:3.6.5
如果你安装的版本不同,那就改数字就行,比如3.5.2 ?!那就把下面的所有的3.6.5改为3.5.2。
1. 安装依赖库:
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
2. 下载Python 3.6.5:
mkdir -p /etc/python3.6
cd /etc/python3.6
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
3. 解压下载的软件包:
sudo tar xzf Python-3.6.5.tgz
4. 编译Python源:
cd Python-3.6.5
sudo ./configure --enable-optimizations --prefix=/etc/python3.6
sudo make altinstall
5. 建立python3.6的软链
ln -s /etc/python3.6/bin/python3.6 /usr/bin/python3.6
ln -s /etc/python3.6/bin/pip3.6 /usr/bin/pip3.6
6.将/etc/python3.6/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:/etc/python3.6/bin
export PATH
使生效
source ~/.bash_profile
---End---
网友评论