ubuntu安装pyenv
时间: 2023-11-28 08:44:19 浏览: 57
以下是在Ubuntu上安装pyenv的步骤:
1. 安装依赖项
```shell
sudo apt-get update
sudo apt-get install -y make 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 python-openssl git
```
2. 克隆pyenv仓库
```shell
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
```
3. 配置环境变量
```shell
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
```
4. 检查pyenv是否安装成功
```shell
pyenv --version
```
5. 安装Python版本
```shell
pyenv install 3.8.2
```
6. 设置当前目录下的Python版本
```shell
pyenv local 3.8.2
```
阅读全文