Jupyterhub startup vs user configuration

I have a Jupyterhub instance I’ve deployed to google (GCP) using repo2docker. The instance is currently running fine with several user libs imported via pip, and is using Google Authentication. I am trying to deploy a custom Authenticator but having path issues

All the user pip installs go to /opt/conda/lib/python3.10/site-packages, as does my custom code I’ve been deploying using a pip install to my repo. I deploy a .py file to use the library via my helm config.yaml that tries to import the custom code
The deploy in the help file

extraFiles:
    my_config:
      mountPath: /usr/local/etc/jupyterhub/jupyterhub_config.d/my_jupyterhub_config.py

which deploys a file that starts with

import sys
sys.path.append('/opt/conda/lib/python3.10/site-packages')
from pprint import pprint
pprint(sys.path)
from oauthenticator.github import GitHubOAuthenticator
from oauthenticator.google import GoogleOAuthenticator
from multiOAuthenticator.multiOAuthenticator import MultiOAuthenticator

I can see the library in the /opt/conda/lib/python3.10/site-packages directory, but get an error on startup of the following.

Loading /usr/local/etc/jupyterhub/jupyterhub_config.d config: my_jupyterhub_config.py
['/usr/local/etc/jupyterhub',
 '/usr/local/bin',
 '/usr/local/lib/python39.zip',
 '/usr/local/lib/python3.9',
 '/usr/local/lib/python3.9/lib-dynload',
 '/usr/local/lib/python3.9/site-packages',
 '/opt/conda/lib/python3.10/site-packages']
[E 2023-05-09 01:19:52.684 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 485, in <module>
        exec(compile(source=file_content, filename=file_name, mode="exec"))
      File "my_jupyterhub_config.py", line 8, in <module>
    ModuleNotFoundError: No module named 'multiOAuthenticator'

This code seems to import and otherwise look ok vscode

Can somebody explain to me what happens on startup that doesn’t use the same python/libs and how I can get the startup to work? I have tried many things, but just cannot get the import to work on startup

thanks
-craig

It looks like you’ve got a mix of python 3.9 and 3.10. Is your hub using a different environment?

If you need more help a full reproducible example would be useful.

“Is your hub using a different environment?”

That’s exactly it. I run a helm upgrade and my .py file runs in 3.9. The library I want, which is in the 3.10 area, is not found and the pod crashes.

I’ll see about putting together an example