# What's a good way to get python 3.7+ (with pip) onto a non-python project?

**URL:** <https://travis-ci.community/t/whats-a-good-way-to-get-python-3-7-with-pip-onto-a-non-python-project/11209>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** python\
**Created:** [February 24, 2021, 2:07pm UTC](https://travis-ci.community/t/whats-a-good-way-to-get-python-3-7-with-pip-onto-a-non-python-project/11209 "2021-02-24T14:07:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oakkitten](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/oakkitten/32/6221_2.png) [@oakkitten](https://travis-ci.community/u/oakkitten)\
**Post date:** [February 24, 2021, 2:07pm UTC](https://travis-ci.community/t/whats-a-good-way-to-get-python-3-7-with-pip-onto-a-non-python-project/11209/1 "2021-02-24T14:07:19Z")

</div>

I’ve got a an android project and I need to have python 3.7+ and pip on the command line. Xenial seems to be providing 3.4 (documentation says 3.5 but that’s not what I see), Focal 3.6, Bionic 3.2 (again, documentation says 3.6). Also, despite what the documentation says, the build works only when I don’t specify `dist: trusty`.

How do I go about installing python 3.7+ and pip?

What I tried:

- 

```travis
addons:
  apt:
    sources:
      - deadsnakes
    packages:
      - python3.7

```

This doesn’t come with `pip`

- same, but with with packages like this:

- 

```travis
    packages:
    - python3.7-venv

before_script:
  - python3.7 -m venv ~/venv
  - source ~/venv/bin/activate

```

This fails due to the following:

> pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Including `libssl-dev` or `python3-openssl` doesn’t help. A similar error breaks the following:

```travis
before_script:
  - curl https://bootstrap.pypa.io/get-pip.py | sudo python3.7 -

```

- 

```travis
    packages:
    - python3.7-venv

before_script:
  - python3.7 -m ensurepip --upgrade

```

This fails due to:

> No module named ensurepip

- 

```travis
before_script:
  - pyenv install --skip-existing 3.6.0 && pyenv global 3.6.0

```

this works, but the highest stable version is somehow 3.6, and also this slows down the build considerably

---

<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:** [February 25, 2021, 12:31am UTC](https://travis-ci.community/t/whats-a-good-way-to-get-python-3-7-with-pip-onto-a-non-python-project/11209/2 "2021-02-25T00:31:24Z")

</div>

- Use `dist: focal` which [comes with `3.8.2`](https://packages.ubuntu.com/focal/python3); or
- install the necessary version with `pyenv` and cache the result

> [@Specifying Python version on build that uses multiple languages](https://travis-ci.community/t/specifying-python-version-on-build-that-uses-multiple-languages/9054/4):
>
> Note that this is going to stop working ifwhen Travis changes their storage location and/or schema. A more sustainable solution would be to install the extra version from source with pyenv and cache the result. In any case, as you’ve correctly guessed, you need to install any language software yourself whenever language: is not it and it’s not preinstalled.

> [@\`pyenv global 3.8.0\` does not change the python version on mac os](https://travis-ci.community/t/pyenv-global-3-8-0-does-not-change-the-python-version-on-mac-os/10146/4):
>
> Add eval "$(pyenv init -)" (note the quotes) to your script to add Pyenv shims directory to PATH. You likely want to add /Users/travis/.pyenv/versions to cache and do pyenv install -s to avoid building Python from source anew every time.
