# No module named kubernetes when creating custom kubernetes image

**URL:** <https://discourse.jupyter.org/t/no-module-named-kubernetes-when-creating-custom-kubernetes-image/14996>\
**Category:** Zero to JupyterHub on Kubernetes\
**Created:** [July 19, 2022, 1:10pm UTC](https://discourse.jupyter.org/t/no-module-named-kubernetes-when-creating-custom-kubernetes-image/14996 "2022-07-19T13:10:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Case\_Joe](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/case_joe/32/6102_2.png) [@Case\_Joe](https://discourse.jupyter.org/u/Case_Joe)\
**Post date:** [July 19, 2022, 1:10pm UTC](https://discourse.jupyter.org/t/no-module-named-kubernetes-when-creating-custom-kubernetes-image/14996/1 "2022-07-19T13:10:05Z")

</div>

Hi, I am trying to build a custom image of a jupyterhub container to be deployed using Kubernetes and helm. I am starting from the GitHub Repository [GitHub - jupyterhub/zero-to-jupyterhub-k8s: Helm Chart & Documentation for deploying JupyterHub on Kubernetes](https://github.com/jupyterhub/zero-to-jupyterhub-k8s), copying the /images/hub directory and creating the Container image with Docker. As authenticator I am using the keycloak Authenticator, whch I am manually adding to the requirements.txt.  
When I am starting the Container, I get the error „no module named kubernetes“. Exploring the requirements.txt, I recoginze that the module really is missing here. After manually adding it, the container starts, but when I want to spawn the Single User notebook, I get the error message:  
expected object of type ‘dict’ (or ‘V1Container’) but got ‘V1Container’  
I am pretty sure this is caused by the kubernetes module, but I have no idea how to fix this.

---

<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:** [July 19, 2022, 1:33pm UTC](https://discourse.jupyter.org/t/no-module-named-kubernetes-when-creating-custom-kubernetes-image/14996/2 "2022-07-19T13:33:03Z")

</div>

Hi!  
Please could you tell us which version of Z2JH you’re using, and which version of the container or Dockerfile you’re using as your base image? Thanks!

---

<div class="post-metadata">

**Author:** ![Case\_Joe](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/case_joe/32/6102_2.png) [@Case\_Joe](https://discourse.jupyter.org/u/Case_Joe)\
**Post date:** [July 19, 2022, 1:36pm UTC](https://discourse.jupyter.org/t/no-module-named-kubernetes-when-creating-custom-kubernetes-image/14996/3 "2022-07-19T13:36:16Z")

</div>

Yes, I am using the Z2JH main branch of [GitHub - jupyterhub/zero-to-jupyterhub-k8s: Helm Chart & Documentation for deploying JupyterHub on Kubernetes](https://github.com/jupyterhub/zero-to-jupyterhub-k8s), the base image in the Dockerfile ([zero-to-jupyterhub-k8s/Dockerfile at 58d7d67192930b95bc1ea14542aabbf04d2605b3 · jupyterhub/zero-to-jupyterhub-k8s · GitHub](https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/58d7d67192930b95bc1ea14542aabbf04d2605b3/images/hub/Dockerfile)) is python:3.9-slim-bullseye

---

<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:** [July 21, 2022, 3:05pm UTC](https://discourse.jupyter.org/t/no-module-named-kubernetes-when-creating-custom-kubernetes-image/14996/4 "2022-07-21T15:05:28Z")

</div>

Could you show us the exact commands you’re using to deploy your Helm Chart, your config, and the Dockerfile for your Hub image? The reliance on the `kubernetes` dependency suggests something might be out of date.
