Change default version of Python to 3.6

I have an R package that, under some circumstances, depends on the Python system installation. This currently seems to be 2.7. How can I set the default python version for an R project? Will you change the default version to 3.6 at some point?

AFAICS there’s no such thing as “default python version for an R project”.
Some R packages interface with Python but how to instruct them which Python to use is package-specific.

E.g. googling “default python version for an R project” shows the docs on this for scrobbler and reticulate.

I mean python is installed in the container. And it’s python 2.7 as shown in the log of my package. I tried TRAVIS_PYTHON_VERSION env variable and python: 3.6 in the .travis.yml file.

Until Ubuntu releases recognizes Python 3 (.6 or later) as the default python, you have to work around this limitation. For example, use dist: bionic, run sudo apt-get install python3 and invoke python3:

language: r
dist: bionic
  - sudo apt-get install python3

You need Bionic to get a Ubuntu-supported 3.6.x.

CAVEAT: Currently R jobs on bionic is currently using a wrong image, so this does not work.

Thanks guys. @BanzaiManI am not sure I correctly understand your suggestion. Since you say for R, bionic is not working, I can’t really use your suggestion? I tried sudo apt-get install python3 and installing pip3 with distr: xenial but it failed with various errors.

Xenial provides only Python 3.5.

Until we fix the image selection issue that I mentioned in the previous comment, it does not work.

You can install Python 3.6 in Xenial R image via preinstalled pyenv (which builds it from source, so you’d better cache the result), or from a 3rd-party PPA e.g. as per