# Installing python \>=3.6 in a cpp image

**URL:** <https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550>\
**Category:** Python\
**Created:** [December 20, 2018, 10:40pm UTC](https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550 "2018-12-20T22:40:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottgigante](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/scottgigante/32/1271_2.png) [@scottgigante](https://travis-ci.community/u/scottgigante)\
**Post date:** [December 20, 2018, 10:40pm UTC](https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550/1 "2018-12-20T22:40:55Z")

</div>

I’m having trouble with installing `python3.6` and `python3.7` from `deadsnakes` in a `cpp` image.

```
Build: Installing APT Packages
10.75s$ travis_apt_get_update
0.51s$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install g++-4.8 libblas-dev liblapack-dev gfortran cmake libboost-all-dev libgsl0-dev libeigen3-dev python3.6
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python3.6
E: Couldn't find any package by glob 'python3.6'
E: Couldn't find any package by regex 'python3.6'

```

Build link: [https://travis-ci.com/scottgigante/nmslib/jobs/166355276](https://travis-ci.com/scottgigante/nmslib/jobs/166355276)  
apt config:

```
addons:
  apt:
    update: true
    sources:
    - ubuntu-toolchain-r-test
    - deadsnakes
    packages: &core_build
    - g++-4.8
    - libblas-dev
    - liblapack-dev
    - gfortran
    - cmake
    - libboost-all-dev
    - libgsl0-dev
    - libeigen3-dev

matrix:
  fast_finish: true
  include:
  - os: linux
    env: PYTHON=3.6
    dist: xenial
    addons:
      apt:
        packages:
          - *core_build
          - python3.6
```

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [December 21, 2018, 12:34am UTC](https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550/2 "2018-12-21T00:34:28Z")

</div>

[Xenial only provides Python 3.5.1](https://packages.ubuntu.com/search?suite=xenial&searchon=names&keywords=python3) and [unless your `language:` is `python`, Travis’ logic to install other versions is unavailable.](https://travis-ci.community/t/error-pyenv-version-3-6-not-installed-since-a-week/1400/2)

Use a 3rd-party library that can install various Python versions itself. I can name `multibuild` and `pyenv` from the top of my head.

---

<div class="post-metadata">

**Author:** ![scottgigante](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/scottgigante/32/1271_2.png) [@scottgigante](https://travis-ci.community/u/scottgigante)\
**Post date:** [December 21, 2018, 12:46am UTC](https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550/3 "2018-12-21T00:46:45Z")

</div>

Does that mean that travis is blocking deadsnakes from providing python3.6? 3.6 and 3.7 are available from ppa:deadsnakes which I have provided in my apt sources.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [December 21, 2018, 12:57am UTC](https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550/4 "2018-12-21T00:57:59Z")

</div>

The problem here is the configuration. Your jobs are not getting the required APT source `deadsnakes`. In your configuration, you define `apt` [at the top level](https://github.com/scottgigante/nmslib/blob/2af1de49f0e5b7d47ab40ec0ef06310b566edf78/.travis.yml#L6-L19) but it is [overridden](https://github.com/scottgigante/nmslib/blob/2af1de49f0e5b7d47ab40ec0ef06310b566edf78/.travis.yml#L35-L39) by the jobs. YAML does not perform any deep merge like this.

---

<div class="post-metadata">

**Author:** ![scottgigante](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/scottgigante/32/1271_2.png) [@scottgigante](https://travis-ci.community/u/scottgigante)\
**Post date:** [December 21, 2018, 2:17pm UTC](https://travis-ci.community/t/installing-python-3-6-in-a-cpp-image/1550/5 "2018-12-21T14:17:33Z")

</div>

Thanks very much! I moved the `sources: - deadsnakes` to the job level and that fixed it.
