背景:ubuntu16.04自带python2.7.12,python3.5.2,把python版本切换为了python3.5,用的是这样的办法:
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
# update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
目标:安装python3.7并将默认版本设置为python3.7
方法:最好不要卸载python3.5,卸载后桌面将用不了
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1rc2.tgz
解压
tar zxvf Python-3.7.1rc2.tgz
cd Python-3.7.1rc2
编译
./configure
make
apt-get
install
-y zlib*
apt-get install --reinstall zlibc zlib1g zlib1g-dev
apt-get install libffi-dev libssl-dev libreadline-dev -y
make install
找的python3.7解释器位置,一般是
/usr/local/bin/python3.7
删除原来的软连接
rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
rm -rf /usr/bin/pip
#添加python3的软链接
ln -s /usr/local/bin/python3.7 /usr/bin/python3
#添加 pip3 的软链接
ln -s /usr/local/bin/pip3.7 /usr/bin/pip3
ln -s /usr/local/bin/pip3.7 /usr/bin/pip
升级pip
安装python的包遇到:
ERROR: tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you'll have setuptools 39.0.1 which is incompatible.
解决:
sudo pip install setuptools==41.0.0,会自动先卸载39.0.1的setuptools的
python3.x安装pip3
sudo apt-get install python3-pip