title: How to install Python on Gitlab-CI
body: <p>How do you install various versions of Python on Gitlab-CI?</p>
  
  <p>In my previous experience with Travis-CI, I simply run the normal Ubuntu/Debian commands to install the deadsnakes repo and then install whatever version I need like:</p>
  
  <pre><code>sudo add-apt-repository -y ppa:fkrull/deadsnakes
  sudo apt-get -yq update
  sudo apt-get -yq install python2.7 python2.7-dev python3.4 python3.4-dev python3.6 python3.6-dev python3.7 python3.7-dev
  </code></pre>
  
  <p>I've tried this similar configuration with Gitlab-CI:</p>
  
  <pre><code>image: ubuntu:latest
  
  before_script:
    - add-apt-repository -y ppa:fkrull/deadsnakes
    - apt-get -yq update
    - apt-get -yq install python2.7 python2.7-dev python3.4 python3.4-dev python3.6 python3.6-dev python3.7 python3.7-dev
    - python -V
  
  test:
    script:
    - ./run_my_tests.sh
  </code></pre>
  
  <p>but this fails with:</p>
  
  <pre><code>/bin/bash: line 82: add-apt-repository: command not found
  </code></pre>
  
  <p>I can only assume that even though I'm running an Ubuntu image, Gitlab restricts the commands available. What's the equivalent way to install Python in Gitlab-CI?</p>