python2和python3共存方法

拿到安装包,安装python3

centos: 

sudo yum install python36

ubuntu:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6

 

安装pip并升级到最新版本:

python -m pip install --upgrade pip

python3 -m pip install --upgrade pip

 

 

如果发现python3安装没有带pip:

 

python3 -m ensurepip

 

 

检查python2和python3是否分开:

pip -V

pip 19.2.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)

pip3 -V

 

pip 19.2.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

 

升级pip后,找不到pip:

whereis pip

使用软链接:

sudo ln -s /usr/bin/pip2.7  /usr/bin/pip

 

posted @ 2019-07-26 15:15  道以万计  阅读(848)  评论(0编辑  收藏  举报