NameError: name 'sys' is not defined when trying to use jupyterhub-idle-culler

Hello, I am trying to add jupyterhub-idle-culler to a jupyterhub (installed with pip3 install jupyterhub):

pip3 install jupyterhub-idle-culler

nano /etc/jupyterhub/jupyterhub_config.py

[...]
c.JupyterHub.load_roles = [
    {
        "name": "jupyterhub-idle-culler-role",
        "scopes": [
            "list:users",
            "read:users:activity",
            "read:servers",
            "delete:servers",
            # "admin:users", # if using --cull-users
        ],
        # assignment of role's permissions to:
        "services": ["jupyterhub-idle-culler-service"],
    }
]
[...]
c.JupyterHub.services = [
    {
        "name": "jupyterhub-idle-culler-service",
        "command": [
            sys.executable,
            "-m", "jupyterhub_idle_culler",
            "--timeout=604800",
        ],
        # "admin": True,
    }
]
[...]

But when I try to start Jupyterhub I have the error:

jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

NameError: name 'sys' is not defined

Solved by adding import sys at the beginning of jupyterhub_config.py… not super elegant although…

if you write a python script that references modules such as sys, you do need to import them before using them. Maybe it’s not clear that jupyterhub_config.py is a regular Python script that’s being executed? The only thing that’s special about it is injecting a single c variable (or get_config()) to the namespace. Otherwise, all your standard practices for writing Python code should apply, including imports, etc.