foreword
Software Environment
Ubuntu Server 20.04 LTS bash 5.0.17 pyenv 2.2.5
- pyenv github: https://github.com/pyenv/pyenv
install pyenv
- Install dependencies
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
- Install
# git 克隆
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
# 编译加速(可选)
cd ~/.pyenv && src/configure && make -C src
- Add in
~/.profile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# 没有这句,下面的镜像 url 不生效
export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1
# 国内 Python 镜像
export PYTHON_BUILD_MIRROR_URL="https://mirrors.huaweicloud.com/python/"
# OR
export PYTHON_BUILD_MIRROR_URL="https://npm.taobao.org/mirrors/python/"
eval "$(pyenv init --path)"
- Add in
~/.bashrc
eval "$(pyenv init -)"
- restart the shell
exec $SHELL
Basic usage of pyenv
- View Installable Python Versions
pyenv install -l
- Install the specified version of Python
pyenv install 3.9.12 -v
- View installed Python versions
$ pyenv versions
* system (set by /home/qbit/.pyenv/version)
3.6.15
3.9.12
- Switch Python version
pyenv global 版本号 设置当前全局python版本
pyenv local 版本号 设置局部python版本
pyenv local --unset 取消局部python版本设置,或者删除当前目录下的.python-version文件
This article is from qbit snap
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。