首先安装依赖
yum install lbzip2 openssl-devel readline-devel bzip2-libs gcc sqlite-devel bzip2-devel openssl-libs zlib -y
安装git
yum install git -y
安装pyenv
curl https://pyenv.run | bash
在此步容易出现错误
访问不到github
Failed to git clone https://github.91chi.fun//https://github.com/pyenv/pyenv.git
解决办法:在家目录新建个脚本
#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x
if [ -z "$PYENV_ROOT" ]; then
export PYENV_ROOT="${HOME}/.pyenv"
fi
colorize() {
if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
else echo -n "$2"
fi
}
# Checks for `.pyenv` file, and suggests to remove it for installing
if [ -d "${PYENV_ROOT}" ]; then
{ echo
colorize 1 "WARNING"
echo ": Can not proceed with installation. Kindly remove the '${PYENV_ROOT}' directory first."
echo
} >&2
exit 1
fi
failed_checkout() {
echo "Failed to git clone $1"
exit -1
}
checkout() {
[ -d "$2" ] || git -c advice.detachedHead=0 clone --branch "$3" --depth 1 "$1" "$2" || failed_checkout "$1"
}
if ! command -v git 1>/dev/null 2>&1; then
echo "pyenv: Git is not installed, can't continue." >&2
exit 1
fi
if [ -n "${USE_GIT_URI}" ]; then
GITHUB="git://github.com"
else
GITHUB="https://gitee.com/"
fi
checkout "${GITHUB}/xbmlz/pyenv.git" "${PYENV_ROOT}" "${PYENV_GIT_TAG:-master}"
checkout "${GITHUB}/xbmlz/pyenv-doctor.git" "${PYENV_ROOT}/plugins/pyenv-doctor" "master"
checkout "${GITHUB}/xbmlz/pyenv-installer.git" "${PYENV_ROOT}/plugins/pyenv-installer" "master"
checkout "${GITHUB}/xbmlz/pyenv-update.git" "${PYENV_ROOT}/plugins/pyenv-update" "master"
checkout "${GITHUB}/xbmlz/pyenv-virtualenv.git" "${PYENV_ROOT}/plugins/pyenv-virtualenv" "master"
checkout "${GITHUB}/xbmlz/pyenv-which-ext.git" "${PYENV_ROOT}/plugins/pyenv-which-ext" "master"
if ! command -v pyenv 1>/dev/null; then
{ echo
colorize 1 "WARNING"
echo ": seems you still have not added 'pyenv' to the load path."
echo
} >&2
{ # Without args, `init` commands print installation help
"${PYENV_ROOT}/bin/pyenv" init || true
"${PYENV_ROOT}/bin/pyenv" virtualenv-init || true
} >&2
fi
这里我改变了一下请求github的连接,然后执行该脚本即可
bash 脚本名
执行完成终端最后有以下美容
Unpacking objects: 100% (10/10), done.
WARNING: seems you still have not added 'pyenv' to the load path.
# Load pyenv automatically by appending
# the following to
~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
and ~/.bashrc (for interactive shells) :
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# Restart your shell for the changes to take effect.
# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:
eval "$(pyenv virtualenv-init -)"
编辑文件
vim ~/.bash_profile
添加如下内容
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
exit
从新登录之后就可以正常使用啦