How to make Python 2/3 available with machine executor type?



When using the machine executor type, how does one enable Python 2 and 3 in the build? For example, invoking python2 in a build causes the following error:

stack Error: Command failed: /opt/circleci/.pyenv/shims/python2 -c import platform; print(platform.python_version());
pyenv: python2: command not found

The `python2' command exists in these Python versions:


The machine executor uses pyenv to manage python versions. That is the best way to manage which version of python you are using in this context.


Thanks @levlaz , but can you please be more specific?

I currently enable Python 2 and 3 respectively through the commands pyenv local 2.7.12 and pyenv local 3.5.2 in my build script. It was through trial and failure that I found that the versions 2.7.12 and 3.5.2 were available. How can one simply enable the latest Python 2/3 versions available in the environment? My build script will break once installed Python versions change.

Also, is this documented anywhere? I really feel in the dark when it comes to the machine executor type, as for how to configure it.