Skip to content

Pyenv Usage: Command Line

Papa Bear Codes Python edited this page Jan 3, 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)

List versions

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

To list the version available for your OS type:

pyenv install --list

You can pick a version the install. The version you selected is what you will use to replace <version> with in the installation and activation instructions.

Install Python Version

To install a particalar python version use the command:

pyenv install <version>

Activation

After installing a particular version/flavor of python you can activate it locally or globally

Locally

No .python-version file present

If there is no .python-version file in your current directory then type:

pyenv local <version>

This will create a file .python-version in your current directory.

.python-version file present

If there is a .python-version file in your current directory then type:

pyenv local

This will activate the version of python/flavor designated in the .python-version file.

Globally

Type the command:

pyenv global <version>

This is now the version available when you have not designated a local version. Pretty much, if you don't have a .python-version file and have designated a global version, then the command python will be the global version.

What version of python?

Command

To figure out what version of python you are using type the command:

python --version

Result

  1. If you get an error that python command is not found. You do not have a current active python version.
  2. If a version returns than it either comes from a global and local install.
Clone this wiki locally