Skip to content

Pyenv: Installation

Papa Bear Codes Python edited this page Jan 31, 2024 · 1 revision

Document Release Date: 1/2/2024

Note: In the I.T. world, applications evolve rapidly. Please report any inaccuracy to papabearcodespython@gmail.com


Why use pyenv?

Pyenv is a python version/flavor installer, that allows you install multiple versions and flavors of python on the same machine.

NOTE: !!!The version/flavor of python available to you will depend highly on the OS you are running.!!!

For example:

  • It allows you to have python version 3.9.0 and 3.10.6 installed at the same time. However, only on can be active at the time.
  • It allows for plain python installations as well as anaconda

There are two different type of python version/flavor selections:

  • Locally (Creates a .python-version file in your current directory when activating the python version/flavor)
  • Globally (Active for the entire machine)

Pre-requirements

Windows

Pyenv is _**not officially supported**_ on windows, therefore we are using a fork of Pyenv called pyenv-win

Install with pip

https://github.com/pyenv-win/pyenv-win/blob/master/docs/installation.md#python-pip

Install with Powershell

See Installation Link

Install with Chocolatey

You will need to install the package manager Choco

NOTE: You must have adminstrator access to install Choco

  1. Open a Powershell' command box with Adminstrator Access`
  2. Run the following command
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  1. If you did not get any errors type: choco which will return the version of Choco

Documentation

Official Installation Doc

Mac

You will need to install the package manager Brew

Official Installation Doc

Linux (Ubuntu)

You will need to execute the following commands

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

For other flavor on Linux see this documentation

Install PyEnv

Windows

Run the following command in an ELEVATED ADMINSTRATOR COMMAND LINE!

choco install pyenv-win

Mac

Run the following command logged in as the current user that has adminstrator access to your machine!

brew install pyenv

Linux

Run the following command in the user home directory.

cd ~
curl https://pyenv.run | bash 
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc 

Usefull Links

Clone this wiki locally