Python 3.7 issue with Kubernetes python client

8/16/2019

I am using a Kubernetes python client package for hitting Kubernetes APIs: https://github.com/kubernetes-client/python

Till now i was using Python 3.6 and this package was working. Now our environment is changed from Python 3.6 to Python 3.7 and while using the same package, i am getting below error while importing this client:

    from kubernetes import client
  File "/usr/local/lib/python3.7/site-packages/kubernetes/__init__.py", line 19, in <module>
    import kubernetes.client
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/__init__.py", line 540, in <module>
    from .apis.admissionregistration_api import AdmissionregistrationApi
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/__init__.py", line 4, in <module>
    from .admissionregistration_api import AdmissionregistrationApi
  File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/admissionregistration_api.py", line 120
    async=params.get('async'),
        ^
SyntaxError: invalid syntax

Is it possible to resolve this with any workaround?

-- Varun Chadha
kubernetes
python
python-3.7

1 Answer

8/16/2019

async has become a keyword in Python 3.7, and it's not possible to assign to keywords and use them as variable names in general.

Quote from the docs:

Backwards incompatible syntax changes:

  • async and await are now reserved keywords.

You'll have to use a lower version of Python where it's not a keyword yet. You can also file a bug report to the devs of the library.

-- ForceBru
Source: StackOverflow