如何安装指定版本的py
查看当前的python版本
python --version
python3 --version
装git
yum update -y && yum install git -y
apt update -y && apt install git -y
apk update && apk add git
下载pyenv管理
curl https://pyenv.run | bash
编辑变量文件
nano ~/.bashrc
添加pyenv的变量
export PYENV_ROOT="$HOME/.pyenv"
if [[ -d "$PYENV_ROOT/bin" ]]; then
export PATH="$PYENV_ROOT/bin:$PATH"
fi
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
重新加载bashrc
source ~/.bashrc
查看pyenv的版本
pyenv --version
安装依赖
# CentOS
yum groupinstall "Development Tools" -y
yum install openssl-devel bzip2-devel libffi-devel ncurses-devel zlib-devel readline-devel sqlite-devel xz-devel findutils -y
# Ubuntu/Debian
apt install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev libgdbm-dev libnss3-dev libedit-dev -y
apk add --no-cache bash gcc musl-dev libffi-dev openssl-dev bzip2-dev zlib-dev readline-dev sqlite-dev libc6-compat linux-headers make xz-dev build-base ncurses-dev
查看可以安装的版本
pyenv install --list
安装对应版本
pyenv install 3.12.4
全局应用对应版本
pyenv global 3.12.4
查看当前的python版本
python --version
python3 --version
删除所有版本
for version in $(pyenv versions --bare); do pyenv uninstall -f $version; done
评论
发表评论