Installing Python 3.6 in machine executor?



How do I install Python 3.6 when using the machine executor?

What is installed in circleci 2.0 machine circleci/classic:xxxx VMs?

You can either install it straight on the VM with packages as you might on your local machine. Or via Docker,

docker pull python:3.6


What does “install it straight on the VM with packages” mean? Do I have to use pyenv, apt-get or is there a convenience method for installing it in config.yml like there used to be with circle.yml.

Also, what does docker pull python:3.6 do for me? It means that I know have a docker image of Python but how do I use that to run python commands in the machine environment?


@FelicianoTech Still waitiing for a reply to know how to do this.


This will install python3.6 for you:

sudo bash -c "yes | add-apt-repository ppa:jonathonf/python-3.6 && apt-get update && apt-get install -y python3.6"

You can’t reference it as python, but you can use it as python3.6:

root@prealloc-gmlyiros-1494439511631:~# python -V
Python 2.7.6
root@prealloc-gmlyiros-1494439511631:~# python3 -V
Python 3.4.3
root@prealloc-gmlyiros-1494439511631:~# python3.6 -V
Python 3.6.1



Is using an untrusted PPA really the only solution? Do you really expect CircleCI users to install random software off the internet in CircleCI 2.0 just to get functionality that was available in 1.0?


Well you can use a Docker image for it, but since you asked what docker pull python:3.6 does for you, that doesn’t sound like a solution for you. Instead, I put in the effort to find a way to install python3.6 on the system to make it accessible as normal.

Python 3.4 is already installed on the system so you can choose which route is best for you.


There’s plenty of solutions. CircleCI is a Linux environment and you can install it in the several ways you could locally on a Linux environment.

  1. Docker image - this is the “convenience method” that you speak of on CircleCI 2.0. I gave you the command for that earlier for the machine executor. For the docker executor, it’s even easier as your commands would be placed directly in the image.
  2. Use the PPA @rohara mentioned or find your own. I’m sure there’s a few around.
  3. Find a .DEB file.
  4. The most secure and safe method, download the tarbar from, verify signitures, and build/compile from source.

The options are listed from least work to most work. I suggest going the Docker route. You can use the official Docker Library images (as I original shared) or CircleCI’s images:

With the machine executor, if you’re not using a custom image, you can just run commands in the container:

If you really want the one-liner via the circle.yml method, you can just use CircleCI 1.0. It isn’t going anywhere anytime soon. 2.0 isn’t a forced upgrade though I strongly suggest looking into Docker more with 2.0. Once you learn it, you’ll be fairly happy with the advantageous it brings to CI.


I tried running sudo apt-get update && sudo apt-get install -y python3 and is said python3 is already the newest version. But then when running python3 it errors out with:

pyenv: python3: command not found

The `python3' command exists in these Python versions:

Exited with code 127

How can I run python3 in the machine executor? Can an example be provided?


Python 3.4.3 is available pre-installed in the machine executor. Without doing anything else, running python3.4 will give that that interpreter. For example:

- python3.4 --version


@FelicianoTech Is there a way to make python3 be an alias for python3.4? The scripts we use are generic for running outside of CircleCI as well, so putting a specific version isn’t an option.


The two options that come to mind is to create a symlink or a Bash alias.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.