Solution
Use pyenv
and rbenv
How It Works?
These tools create a shim (or think of softlinks
) for a version of the software. You can choose to run a version globally or locally in a shell. Switch to a version anytime you like.
Run Python 3 & Python 2 without much trouble. Or no need to manually get all Ruby dependencies for a given version.
Example for MacOS
$ brew install rbenv
$ $ rbenv versions
system
2.3.0
* 2.3.6 (set by /Users/<xyz>/.rbenv/version)
2.6.0
- Install a new version
$ rbenv install 2.3.6
- Switch globally to a different version
$ rbenv global 2.3.0
Update the bundler
if changing the Ruby version.
gem install bundler
The same commands apply to pyenv
.
Internal Working
At a high level, pyenv intercepts Python commands using shim executables injected into your
PATH
, determines which Python version has been specified by your application, and passes your commands along to the correct Python installation.