# kubernetes.core.helm throwing Invalid Syntax

**URL:** <https://forum.ansible.com/t/kubernetes-core-helm-throwing-invalid-syntax/36876>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [July 20, 2022, 12:41pm UTC](https://forum.ansible.com/t/kubernetes-core-helm-throwing-invalid-syntax/36876 "2022-07-20T12:41:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEEPANSHU\_DANG](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DEEPANSHU\_DANG](https://forum.ansible.com/u/DEEPANSHU_DANG)\
**Post date:** [July 20, 2022, 12:41pm UTC](https://forum.ansible.com/t/kubernetes-core-helm-throwing-invalid-syntax/36876/1 "2022-07-20T12:41:42Z")

</div>

Hi team,

I’m running ansible on centos 7 in which python 2 coming by default and some dependencies like yum etc is depended on that.

When Ansible is install it picking the default python2 as INTERPRETER

Ansible --version  
ansible 2.9.27 config file = /etc/ansible/ansible.cfg configured module search path = [u’/home/centos/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible **python version = 2.7.5** (default, Jun 28 2022, 15:30:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

With the following link: I have set the Python INTERPRETER as Environment

IniSection [defaults]  
Key interpreter\_python  
EnvironmentVariable [ANSIBLE\_PYTHON\_INTERPRETER](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_PYTHON_INTERPRETER)  
Variablesname ansible\_python\_interpreter

But when I try executing kubernetes.core.helm: modules its throwing me an error:

TASK [adding] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [ansible\_host=“HOST IP”]: FAILED! =\> {“msg”: “Unable to import kubernetes.core.helm due to invalid syntax”}

here is my sample playbook

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [July 21, 2022, 4:40am UTC](https://forum.ansible.com/t/kubernetes-core-helm-throwing-invalid-syntax/36876/2 "2022-07-21T04:40:17Z")

</div>

Python 2 is End of life and not supported by Ansible. Also, kubernetes.core collection is supported on Python3 ([https://github.com/ansible-collections/kubernetes.core#python-support](https://github.com/ansible-collections/kubernetes.core#python-support)). I would recommend you upgrade to the latest Python version. After installing the latest Python 3 version use

```auto
---
- hosts: localhost
vars:
ansible_python_interpreter: /Path/to/bin/python3
tasks:
...

```

or

```auto

export ANSIBLE_PYTHON_INTERPRETER=/path/to/bin/python3

```

then run the playbook.

Apart from that `--syntax-check` would provide syntax errors for YAML files, not for the actual module that is being invoked.

---

<div class="post-metadata">

**Author:** ![DEEPANSHU\_DANG](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@DEEPANSHU\_DANG](https://forum.ansible.com/u/DEEPANSHU_DANG)\
**Post date:** [October 31, 2022, 9:16am UTC](https://forum.ansible.com/t/kubernetes-core-helm-throwing-invalid-syntax/36876/3 "2022-10-31T09:16:36Z")

</div>

Thanks Abhijeet for the answer

Using ansible in centos 7 in which python2 is set as default interpreter and some utilities is based on python2 like yum so can not change the python interpreter as default

Even try setting up python interpreter

- within playbook
- in Ansible.cfg
- in inventory hosts file
- as environment variable  
but no go anything else we you can suggest
