目录

pyenv

pyenv is a Simple Python version management.

I use it on CentOS 6 because upgrade system's python 2.6 would broke many things.

Installation

git clone https://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

Usage

Install requirement: [(https://github.com/pyenv/pyenv/wiki/Common-build-problems)]

yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel

Install Python 3.6.2:

pyenv install 3.6.2

Use pyenv's python on specify directory:

cd /path/to/project
pyenv local 3.6.2
python --version   # 3.6.2

Accelerate in China

export VERSION="3.6.2"
mkdir -p ~/.pyenv/cache/
wget https://npm.taobao.org/mirrors/python/$VERSION/Python-$VERSION.tar.xz -P ~/.pyenv/cache/
pyenv install $VERSION