본문 바로가기
카테고리 없음

파이썬 버전 관리 Pyenv 설치

by Z0e 2025. 4. 3.

 

 

Pyenv 설치

Build Dependencies

sudo apt update; sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

 

 

Installation

curl -fsSL https://pyenv.run | bash

 

  • bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc

 

  • zsh
  echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
  echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
  echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc

 

 

Restart shell

exec "$SHELL"

 

 

Usage

pyenv install 3.12
pyenv global 3.12

 

 

 

 

참고

 

Managing Multiple Python Versions With pyenv – Real Python

In this step-by-step tutorial, you'll learn how to install multiple Python versions and switch between them with ease, including project-specific virtual environments, even if you don't have sudo access with pyenv.

realpython.com