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

**URL:** https://travis-ci.community/t/python-os-system-shell-has-different-java-version-than-the-travis-build-environment/7732
**Category:** Environments
**Tags:** build-env, java
**Created:** [March 23, 2020, 7:01am UTC](https://travis-ci.community/t/python-os-system-shell-has-different-java-version-than-the-travis-build-environment/7732 "2020-03-23T07:01:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![patrick-werner](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@patrick-werner](https://travis-ci.community/u/patrick-werner)
#### Post date: [March 23, 2020, 7:01am UTC](https://travis-ci.community/t/python-os-system-shell-has-different-java-version-than-the-travis-build-environment/7732/1 "2020-03-23T07:01:54Z")

</div>

In a travis build environment:

```auto
language: java
dist: xenial
jdk:
  - openjdk13
script:
  - java -version
  - script.py

```

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.

---

<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: [March 23, 2020, 10:35am UTC](https://travis-ci.community/t/python-os-system-shell-has-different-java-version-than-the-travis-build-environment/7732/2 "2020-03-23T10:35:25Z")

</div>

[This is the handiwork of `pyenv`](https://travis-ci.org/github/native-api/test_travis/builds/665796659). 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`](https://github.com/pyenv/pyenv/blob/master/CHANGELOG.md#1214), 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)"`

---

<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: [March 23, 2020, 10:39am UTC](https://travis-ci.community/t/python-os-system-shell-has-different-java-version-than-the-travis-build-environment/7732/3 "2020-03-23T10:39:13Z")

</div>

@BanzaiMan Could you update Pyenv in Linux images for non-EOL Ubuntu versions to fix this? [They currently support Xenial+](https://github.com/pyenv/pyenv/blob/master/.travis.yml#L20).

---

<div class="post-metadata">

### Author: ![patrick-werner](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@patrick-werner](https://travis-ci.community/u/patrick-werner)
#### Post date: [March 23, 2020, 10:46am UTC](https://travis-ci.community/t/python-os-system-shell-has-different-java-version-than-the-travis-build-environment/7732/4 "2020-03-23T10:46:56Z")

</div>

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