源码:https://github.com/pyenv/pyenv
mkdir /opt/pyenv && cd /opt/pyenv
tar -zxvf pyenv-2.3.22.tar.gz
cd /opt/pyenv/pyenv-2.3.22
src/configure && make -C src
echo '### PYENV ###' >> ~/.bashrc
echo 'export PYENV_ROOT="/opt/pyenv/pyenv-2.3.22"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
mkdir $(pyenv root)/cache
### mkdir `pyenv root`/cache
python_ver=3.6.8
# 阿里镜像源
wget https://npm.taobao.org/mirrors/python/$python_ver/Python-$python_ver.tar.xz -P $(pyenv root)/cache
# 华为镜像源
wget https://mirrors.huaweicloud.com/python/$python_ver/Python-$python_ver.tar.xz -P $(pyenv root)/cache
pyenv install 2.7.18 3.6.8
pyenv global 3.6.8
# pyenv shell : select just for current shell session.
# pyenv local : current directory (or its subdirectories).
# pyenv global : select globally for your user account.
### 更多命令使用请参考帮助文档:pyenv -h