Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Emdadul Huq
Emdadul Huq

Posted on

     

How to Install Pyenv on Ubuntu 24.04

Due to the slowness of repositories or even lack thereof being updated with specific versions of Python, I’ve decided to move some of my environments over to Pyenv to allow me to dynamically install and configure Python specifically for my environment. As it turns out this will also allow VS Code to allow me to choose the version of Python that I’d like to use when testing. So, here’s a quick guide to installing Pyenv on Ubuntu 24.04

Update and install dependencies

we need to ensure our package cache is updated, and then install the dependencies to download, and build python from pyenv.

sudo apt-get update && sudo apt-get install make build-essential
Enter fullscreen modeExit fullscreen mode

Install Pyenv using pyenv-installer

curl https://pyenv.run | bash
Enter fullscreen modeExit fullscreen mode

Configure user profile to use pyenv

Ensure the following is in your ~/.bash_profile (if exists), ~/.profile (for login shells), ~/.bashrc (for interactive shells), or ~/.zshrc

# Load pyenv automatically by appending# the following to # ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)# and ~/.bashrc (for interactive shells) :export PYENV_ROOT="$HOME/.pyenv"[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"eval "$(pyenv init -)"
Enter fullscreen modeExit fullscreen mode

Optionally enable pyenv-virtualenv

eval "$(pyenv virtualenv-init -)"
Enter fullscreen modeExit fullscreen mode

Reload your profile

source ~/.profile
Enter fullscreen modeExit fullscreen mode

Install python using pyenv

pyenv install <version>
Enter fullscreen modeExit fullscreen mode

Set your python version

pyenv shell — select just for current shell session
pyenv local — automatically select whenever you are in the current directory (or its subdirectories)
pyenv global — select globally for your user account

Validate your installation of python

python3 --version
Enter fullscreen modeExit fullscreen mode

ReferencePyenv

Sample

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I'm Emdadul Huq. I love to contribute open-source project.
  • Location
    Dhaka
  • Education
    Begum Rokeya University, Rangpur
  • Pronouns
    Emdadul
  • Work
    Principal Backend Engineer at Real Life Apps
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp