ubuntu pyenv 安装
时间: 2023-08-24 20:08:09 浏览: 156
pyenv-installer
1. 安装依赖
```bash
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
```bash
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
```
3. 配置环境变量
```bash
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. 安装 Python 版本
```bash
pyenv install 3.7.9
```
5. 设置全局 Python 版本
```bash
pyenv global 3.7.9
```
6. 验证安装
```bash
python --version
```
输出结果应该为:
```bash
Python 3.7.9
```
阅读全文