How to install Python with pyenv version manager

I am using different programming languages like C#, Java, Node.js etc.

So, I definitely need to switch between runtime environments.

For example, there are some package managers in Node.js community like nvm or n. I am very happy to use both of two package managers 🙂

Let's say I work for one Node.js project in dev machine with Node v8.0.0 but other project needs Node v6.0.0

In order to handle, different versions in same machine, we may use package managers.

I just want to find a way to switch between different Python version so that found pyenv package manager.

There are also others like asdf, gvmnvmrbenv package managers.

Pyenv installation

Click pyenv link for more detailed installation.

I just want to show Homebrew(click for installation). Homebrew is a Package Manager for macOS

Installing pyenv with Homebrew

Run the following commands in your terminal. But, just copy commands without $ sign.

$ brew update
$ brew install pyenv
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

and restart your terminal.

Upgrading pyenv

$ brew upgrade pyenv

Uninstall pyenv

$ brew uninstall pyenv

Pyenv commands

List all Python versions installed in system

$ pyenv versions
* 3.8.2 (set by /Users/kenanhancer/.pyenv/version)

Show current active Python version in system

$ pyenv version
3.8.2 (set by /Users/kenanhancer/.pyenv/version)
Continue reading