# Trying to upgrade jupyterhub from helm 1.2.0 to 2.0.0

**URL:** <https://discourse.jupyter.org/t/trying-to-upgrade-jupyterhub-from-helm-1-2-0-to-2-0-0/19886>\
**Category:** JupyterHub\
**Tags:** community, release, jupyterhub, how-to, help-wanted\
**Created:** [June 13, 2023, 3:38pm UTC](https://discourse.jupyter.org/t/trying-to-upgrade-jupyterhub-from-helm-1-2-0-to-2-0-0/19886 "2023-06-13T15:38:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suresh](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Suresh](https://discourse.jupyter.org/u/Suresh)\
**Post date:** [June 13, 2023, 3:38pm UTC](https://discourse.jupyter.org/t/trying-to-upgrade-jupyterhub-from-helm-1-2-0-to-2-0-0/19886/1 "2023-06-13T15:38:54Z")

</div>

Hello everyone, I’ve been trying to upgrade helm from 1.2.0 to 2.0.0. I got this error message when I check the logs (ModuleNotFoundError: No module named ‘kubernetes’). So I tried installing kubernetes package. Now I’m getting this error (ModuleNotFoundError: No module named ‘cognitojwt’). But cognitojwt is already installed.

You can check the logs here:

```auto
Loading /usr/local/etc/jupyterhub/secret/values.yaml
No config at /usr/local/etc/jupyterhub/existing-secret/values.yaml
Loading extra config: spawner
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: wheel in /usr/local/lib/python3.9/site-packages (0.37.1)
WARNING: You are using pip version 22.0.4; however, version 23.1.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Defaulting to user installation because normal site-packages is not writeable
Collecting kubernetes
  Downloading kubernetes-26.1.0-py2.py3-none-any.whl (1.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 68.8 MB/s eta 0:00:00
Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages (from kubernetes) (2.28.1)
Requirement already satisfied: python-dateutil>=2.5.3 in /usr/local/lib/python3.9/site-packages (from kubernetes) (2.8.2)
Collecting google-auth>=1.0.1
  Downloading google_auth-2.19.1-py2.py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.3/181.3 KB 35.1 MB/s eta 0:00:00
Requirement already satisfied: certifi>=14.05.14 in /usr/local/lib/python3.9/site-packages (from kubernetes) (2022.6.15.1)
Collecting websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0
  Downloading websocket_client-1.5.3-py3-none-any.whl (56 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.6/56.6 KB 13.1 MB/s eta 0:00:00
Requirement already satisfied: setuptools>=21.0.0 in /usr/local/lib/python3.9/site-packages (from kubernetes) (58.1.0)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.9/site-packages (from kubernetes) (1.16.0)
Requirement already satisfied: requests-oauthlib in /usr/local/lib/python3.9/site-packages (from kubernetes) (1.3.1)
Requirement already satisfied: urllib3>=1.24.2 in /usr/local/lib/python3.9/site-packages (from kubernetes) (1.26.12)
Requirement already satisfied: pyyaml>=5.4.1 in /usr/local/lib/python3.9/site-packages (from kubernetes) (6.0)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 181.3/181.3 KB 40.7 MB/s eta 0:00:00
Collecting rsa<5,>=3.1.4
  Downloading rsa-4.9-py3-none-any.whl (34 kB)
Collecting cachetools<6.0,>=2.0.0
  Downloading cachetools-5.3.1-py3-none-any.whl (9.3 kB)
Requirement already satisfied: charset-normalizer<3,>=2 in /usr/local/lib/python3.9/site-packages (from requests->kubernetes) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests->kubernetes) (3.3)
Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.9/site-packages (from requests-oauthlib->kubernetes) (3.2.0)
Requirement already satisfied: pyasn1<0.6.0,>=0.4.6 in /usr/local/lib/python3.9/site-packages (from pyasn1-modules>=0.2.1->google-auth>=1.0.1->kubernetes) (0.4.8)
Installing collected packages: websocket-client, rsa, pyasn1-modules, cachetools, google-auth, kubernetes
  WARNING: The script wsdump is installed in '/home/jovyan/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/jovyan/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed cachetools-5.3.1 google-auth-2.19.1 kubernetes-26.1.0 pyasn1-modules-0.3.0 rsa-4.9 websocket-client-1.5.3
WARNING: You are using pip version 22.0.4; however, version 23.1.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Defaulting to user installation because normal site-packages is not writeable
Collecting cognitojwt[sync]
  Downloading cognitojwt-1.4.1-py3-none-any.whl (6.6 kB)
Collecting python-jose[cryptography]
  Downloading python_jose-3.3.0-py2.py3-none-any.whl (33 kB)
Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages (from cognitojwt[sync]) (2.28.1)
Requirement already satisfied: rsa in /home/jovyan/.local/lib/python3.9/site-packages (from python-jose[cryptography]->cognitojwt[sync]) (4.9)
Collecting ecdsa!=0.15
  Downloading ecdsa-0.18.0-py2.py3-none-any.whl (142 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 142.9/142.9 KB 22.1 MB/s eta 0:00:00
Requirement already satisfied: pyasn1 in /usr/local/lib/python3.9/site-packages (from python-jose[cryptography]->cognitojwt[sync]) (0.4.8)
Requirement already satisfied: cryptography>=3.4.0 in /usr/local/lib/python3.9/site-packages (from python-jose[cryptography]->cognitojwt[sync]) (38.0.1)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/site-packages (from requests->cognitojwt[sync]) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/site-packages (from requests->cognitojwt[sync]) (2022.6.15.1)
Requirement already satisfied: charset-normalizer<3,>=2 in /usr/local/lib/python3.9/site-packages (from requests->cognitojwt[sync]) (2.1.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/site-packages (from requests->cognitojwt[sync]) (1.26.12)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.9/site-packages (from cryptography>=3.4.0->python-jose[cryptography]->cognitojwt[sync]) (1.15.1)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.9/site-packages (from ecdsa!=0.15->python-jose[cryptography]->cognitojwt[sync]) (1.16.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.4.0->python-jose[cryptography]->cognitojwt[sync]) (2.21)
Installing collected packages: ecdsa, python-jose, cognitojwt
Successfully installed cognitojwt-1.4.1 ecdsa-0.18.0 python-jose-3.3.0
WARNING: You are using pip version 22.0.4; however, version 23.1.2 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
[E 2023-06-13 15:34:01.033 JupyterHub app:3297]
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/site-packages/jupyterhub/app.py", line 3294, in launch_instance_async
        await self.initialize(argv)
      File "/usr/local/lib/python3.9/site-packages/jupyterhub/app.py", line 2773, in initialize
        self.load_config_file(self.config_file)
      File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 110, in inner
        return method(app, *args, **kwargs)
      File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 885, in load_config_file
        for (config, filename) in self._load_config_files(
      File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 844, in _load_config_files
        config = loader.load_config()
      File "/usr/local/lib/python3.9/site-packages/traitlets/config/loader.py", line 625, in load_config
        self._read_file_as_dict()
      File "/usr/local/lib/python3.9/site-packages/traitlets/config/loader.py", line 658, in _read_file_as_dict
        exec(compile(f.read(), conf_filename, "exec"), namespace, namespace)
      File "/usr/local/etc/jupyterhub/jupyterhub_config.py", line 490, in <module>
        exec(config_py)
      File "<string>", line 21, in <module>
    ModuleNotFoundError: No module named 'cognitojwt'

```

This is my config:

```auto
      extraConfig:
        spawner: |
          #!/usr/bin/env python3

          import json
          import os
          import sys
          import base64
          import time
          import requests
          from jupyterhub.handlers import LogoutHandler
          from tornado import web
          # install 'cognitojwt' packages to hub container - require to validate user claim
          try:
            import cognitojwt
          except ImportError:
            import subprocess
            subprocess.call([sys.executable, "-m", "pip", "install", "wheel"])
            subprocess.call([sys.executable, "-m", "pip", "install", "kubernetes"])
            subprocess.call([sys.executable, "-m", "pip", "install", "--user", "cognitojwt[sync]"])
          finally:
            sys.path.append(os.path.expanduser('~') + "/.local/lib/python3.8/site-packages")
            import cognitojwt

          def enum(**enums):
            return type('Enum', (), enums)

          from kubernetes import client, config

          async def verify_claims(self, user):
            # Retrieve user authentication info, decode, and verify claims
            try:
              auth_state = await user.get_auth_state()
              # self.log.info(f"auth_state: {auth_state}")
              if auth_state is None:
                raise ValueError("auth_state is empty")

```

Please let me know if anyone finds out what the exact issue is.

Thank you

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [June 14, 2023, 11:33am UTC](https://discourse.jupyter.org/t/trying-to-upgrade-jupyterhub-from-helm-1-2-0-to-2-0-0/19886/2 "2023-06-14T11:33:31Z")

</div>

> [@Suresh](#):
>
> (ModuleNotFoundError: No module named ‘kubernetes’)

[Z2JH 2.0.0 has several breaking changes](https://z2jh.jupyter.org/en/2.0.0/administrator/upgrading/upgrade-1-to-2.html), including the replacement of `kubernetes` with the `kubernetes_asyncio` Python module

> [@Suresh](#):
>
> ` sys.path.append(os.path.expanduser('~') + "/.local/lib/python3.8/site-packages")`

You’re using `python3.8` in the path, but the earlier logs show `python3.9`

---

<div class="post-metadata">

**Author:** ![Suresh](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Suresh](https://discourse.jupyter.org/u/Suresh)\
**Post date:** [June 14, 2023, 4:35pm UTC](https://discourse.jupyter.org/t/trying-to-upgrade-jupyterhub-from-helm-1-2-0-to-2-0-0/19886/3 "2023-06-14T16:35:41Z")

</div>

Thank you very much, @manics. That worked.
