Python: os.system() shell has different java version than the travis build environment

In a travis build environment:

language: java
dist: xenial
  - openjdk13
  - java -version

The first java -version outputs JDK13, but when using os.system(java -version) inside the python script JDK8 is shown.

I don’t understand why there is a difference, and how to get a JDK13 capable shell from inside the python script as well.

This is the handiwork of pyenv. It prepends a few entries to PATH when Python is run through its shim.

Prepending /usr/bin for system version was removed in 1.2.14, the preinstalled version is older.

To workaround that, run Python directly:

  • /usr/bin/python (or whichever installation you want to use), or
  • "$(pyenv which python)"
1 Like

@BanzaiMan Could you update Pyenv in Linux images for non-EOL Ubuntu versions to fix this? They currently support Xenial+.

Thank you soooooo much. Spent hours on this, now it is working.