在同一台机器上使用不同的python版本

###方法一

1
2
3
4
5
git clone git://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec $SHELL -l

安装python3.6

1
2
3
4
5
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev

pyenv install 3.6.4

###方法二

sudo apt-get install python3

安装pip3:

1
2
3
4
:::text
cd /tmp
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py

faq

解决

解决pyenv list 显示的python版本不够新

  • brew upgrade pyenv
  • pyenv update

##参考资料