App Web Tutorials
  • Home
  • Contact
  • Privacy Policy
Reading: The Ultimate Guide to Installing pyenv on Windows, Ubuntu, and macOS
Share
Subscribe Now
App Web TutorialsApp Web Tutorials
Font ResizerAa
Search
  • Home
  • Contact
  • Privacy Policy
Follow US
Copyright © 2017-2025 App Web Tutorials. All Rights Reserved.
install pyenv Windowspyenvpyenv macOSpyenv UbuntuPython installation

The Ultimate Guide to Installing pyenv on Windows, Ubuntu, and macOS

Chetan
By Chetan
Last updated: January 21, 2025
5 Min Read
How to Install and Use pyenv on Windows, Ubuntu, and macOS: A Complete Guide
How to Install and Use pyenv on Windows, Ubuntu, and macOS: A Complete Guide
SHARE
How to Install and Use pyenv on Windows, Ubuntu, and macOS: A Complete Guide
How to Install and Use pyenv on Windows, Ubuntu, and macOS: A Complete Guide

How to Install and Use pyenv on Windows, Ubuntu, and macOS

Managing multiple Python versions across different operating systems can be a challenge. Whether you’re developing projects that require different Python versions or simply want better control over your development environment, pyenv makes it easy to install, switch, and manage multiple Python versions seamlessly. This guide will walk you through the setup of pyenv on Windows, Ubuntu, and macOS, with detailed instructions for each.

Contents
How to Install and Use pyenv on Windows, Ubuntu, and macOS1. Installing pyenv on WindowsStep 1: Install pyenv-winStep 2: Update Environment VariablesStep 3: Install Python VersionsStep 4: Set the Global or Local Python VersionStep 5: Verify Python Version2. Installing pyenv on UbuntuStep 1: Install DependenciesStep 2: Install pyenvStep 3: Update Shell ConfigurationStep 4: Install Python VersionsStep 5: Set Global or Local Python Version3. Installing pyenv on macOSStep 1: Install Homebrew (If Not Installed)Step 2: Install pyenvStep 3: Update Shell ConfigurationStep 4: Install Python VersionsStep 5: Set Global or Local Python VersionCommon pyenv CommandsConclusion

1. Installing pyenv on Windows

Setting up pyenv on Windows is straightforward thanks to the pyenv-win package.

Step 1: Install pyenv-win
  1. Open PowerShell or Command Prompt as an administrator.
  2. Install pyenv-win with the following command:
    pip install pyenv-win –target C:Users<username>.pyenv
Step 2: Update Environment Variables
  1. Right-click on This PC → Properties → Advanced system settings → Environment Variables.
  2. Under System variables, find and select Path, then click Edit.
  3. Add the following paths:
    C:Users<username>.pyenvpyenv-winbin
    C:Users<username>.pyenvpyenv-winshims
Step 3: Install Python Versions

To install a specific Python version, use:

pyenv install 3.9.5

Replace 3.9.5 with any version you want.

Step 4: Set the Global or Local Python Version

To set a global version of Python:

pyenv global 3.9.5

To set a local Python version for a specific project or directory:

pyenv local 3.9.5
Step 5: Verify Python Version

Check which version of Python is currently active:

pyenv version

2. Installing pyenv on Ubuntu

Setting up pyenv on Ubuntu involves a few dependencies and commands.

Step 1: Install Dependencies

Open the terminal and install dependencies:

sudo apt update
sudo apt 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
Step 2: Install pyenv

Clone the pyenv repository to your home directory:

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Step 3: Update Shell Configuration

Add pyenv to your shell’s startup file (.bashrc or .zshrc):

echo ‘export PYENV_ROOT=”$HOME/.pyenv”‘ >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
source ~/.bashrc
Step 4: Install Python Versions

Install any version of Python using:

pyenv install 3.9.5
Step 5: Set Global or Local Python Version

To set a global Python version:

pyenv global 3.9.5

For a local version:

pyenv local 3.9.5

3. Installing pyenv on macOS

Step 1: Install Homebrew (If Not Installed)

First, install Homebrew (the macOS package manager), if you haven’t already:

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
Step 2: Install pyenv

Once Homebrew is installed, you can easily install pyenv:

brew install pyenv
Step 3: Update Shell Configuration

Add pyenv to your shell configuration file (.bash_profile, .zshrc, or .bashrc):

echo ‘export PYENV_ROOT=”$HOME/.pyenv”‘ >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init --path)"' >> ~/.bash_profile
source ~/.bash_profile
Step 4: Install Python Versions

To install Python 3.9.5 or any version, run:

pyenv install 3.9.5
Step 5: Set Global or Local Python Version

To set a global Python version:

pyenv global 3.9.5

For a local version:

pyenv local 3.9.5

Common pyenv Commands

Here are some useful pyenv commands to manage Python versions:

  • List installed Python versions:
    pyenv versions
  • List available Python versions:
    pyenv install –list
  • Install a specific Python version:
    pyenv install <version>
  • Set global Python version:
    pyenv global <version>
  • Set local Python version:
    pyenv local <version>
  • Check active Python version:
    pyenv version

Conclusion

Whether you’re working on Windows, Ubuntu, or macOS, pyenv is a powerful tool to easily manage multiple Python versions. Follow the steps outlined in this guide to set up pyenv on your system and take full control over your Python development environment.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How to Host a Python Flask App with SSL on WAMP Server in Windows: A Step-by-Step Guide for Beginners
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

FacebookLike
XFollow
InstagramFollow
Most Popular
How to Install and Use pyenv on Windows, Ubuntu, and macOS: A Complete Guide
The Ultimate Guide to Installing pyenv on Windows, Ubuntu, and macOS
January 21, 2025
How to Host a Python Flask App with SSL on WAMP Server in Windows: A Step-by-Step Guide for Beginners
January 21, 2025
Fixing SSH ‘Unprotected Private Key File’ Error in Windows 11: A Quick Guide
Easily Fix the SSH ‘Unprotected Private Key File’ Error on Windows 11 in Minutes
January 20, 2025
How to Add Eye-Catching Animations to Your HTML Website: A Step-by-Step Guide for Beginners
Power Your HTML Website with Stunning Animations: Easy Guide for Beginners
January 15, 2025
Master Git with Ease: The Ultimate Cheatsheet Every Developer Needs
Master Git with Ease: The Ultimate Cheatsheet Every Developer Needs
January 21, 2025

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!
App Web Tutorials

We provide tutorials, tips, tricks, and advice for improving programming and development skills.

Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?