1. 程式人生 > >Ubuntu下Python2與Python3的共存

Ubuntu下Python2與Python3的共存

修改配置

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2 
# 新增Python2可選項,優先順序為2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1 
# 新增Python3可選項,優先順序為1
sudo update-alternatives --config python
--------------------- 
 

出現如下配置選單,發現現在是自動模式,選擇python2,要設定為python3只需要選擇2,enter即可啦~

è¿éåå¾çæè¿°

 

補充

給python2和python3裝上pip,注意不能互相用對方的pip

sudo apt-get install python2-pip
sudo apt-get install python3-pip

 

From: https://blog.csdn.net/weixin_40293491/article/details/81183491