Installing pyenv - RVM for Python

One of the things I’ve missed while learning python, is the ability to manage and switch between python versions.

In Ruby, we often use tools like RVM or rbenv to handle the different ruby versions. This is particularly useful when you have projects that have to rely on an older version of ruby and you don’t want to mess up your local environment.

In python, there’s pyenv.

To set it up, its really quite simple. I’d recommend you use pyenv installer just because its really like RVM’s installation.

$ curl -L | bash

$ pyenv update

And you’re done.

Some of the key things you can do with pyenv:

Check the current version

$ pyenv versions

This is the equivalent of

$ rvm list

List all available python versions

$ pyenv install -l

Equivalent of

$ rvm list known

Installing a python version

$ pyenv install <version>

# example
$ pyenv install 3.5.1
$ rvm install 2.2.0

Set global version (default)

$ pyenv global <version>
$ rvm use <version> --default

Defining project-specific python versions

/path/to/project $ pyenv local <version>

This will create a .python-version file in the current directory and override global versions when working in that directory.

This is the equivalent of the .ruby-version.