0

i am new to python and Kubernetes, i have installed the Kubernetes client, i was trying to get the namespace below is my code:


 from kubernetes import client, config
 def main():

    config.load_kube_config()
    k8s_apps_v1 = client.AppsV1Api()
    resp = k8s_apps_v1.list_namespaced_deployment(
        namespace="some name")
    print(resp)


 if __name__ == '__main__':
    main()

but i am getting the below error :


/usr/local/bin/python3.8 /Users/some name/PycharmProjects/some name/main.py Traceback (most recent call last): enter code hereFile "/Users/some name/PycharmProjects/some name/main.py", line 1, in from kubernetes import client, config File "/Users/some name/Library/Python/3.8/lib/python/site-packages/kubernete/init.py", line 19, in import kubernetes.client File "/Users/some name/Library/Python/3.8/lib/python/site-packages/kubernetes/client/init.py", line 20, in from kubernetes.client.api.well_known_api import WellKnownApi File "/Users/some name/Library/Python/3.8/lib/python/site-packages/kubernetes/client/api/init.py", line 6, in from kubernetes.client.api.well_known_api import WellKnownApi File "/Users/some name/Library/Python/3.8/lib/python/site-packages/kubernetes/client/api/well_known_api.py", line 18, in import six ModuleNotFoundError: No module named 'six'

Process finished with exit code 1


Here is my init file


    # limitations under the License.
    
    __project__ = 'kubernetes'
    # The version is auto-updated. Please do not edit.
    __version__ = "25.0.0-snapshot"
    
    import kubernetes.client
    import kubernetes.config
    import kubernetes.dynamic
    import kubernetes.watch
    import kubernetes.stream
    import kubernetes.utils
    import kubernetes.leaderelection

kumar
  • 1
  • 1
  • I am using Pycharm IDE – kumar Oct 17 '22 at 10:20
  • It seems that you made something false with the installation of the kubernetes package. The package kubernetes has six as a dependency. Did you install it using pip ? – Zackorrigan Oct 17 '22 at 12:18
  • @Zackorrigan Yes i installed it. I tried again and i got this - Defaulting to user installation because normal site-packages is not writeable – kumar Oct 17 '22 at 12:37
  • Is it possible that site-packages directory is only writable by root and if you're using pycharm to install packages it tries to install them as the current user and cannot write them ? – Zackorrigan Oct 17 '22 at 14:36
  • @Zackorrigan you are correct, the path for six was different then other kubernetes module i copied and pasted all the module at same place – kumar Oct 18 '22 at 13:06

0 Answers0