'OAuth - "No module named authlib"

I'm running superset on MacOS in docker and I'm trying to get OAuth working.

I’ve edited the config file /docker/pythonpath_dev/superset_config.py and added the OAuth configuration.

One of the lines I added was

AUTH_TYPE = AUTH_OAUTH

This required me to import the auth types as below:

from flask_appbuilder.security.manager import (
    AUTH_OID,
    AUTH_REMOTE_USER,
    AUTH_DB,
    AUTH_LDAP,
    AUTH_OAUTH,
)

When I try to start up superset with the following command: docker-compose -f docker-compose-non-dev.yml up

I get the following error:

File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/security/manager.py", line 250, in __init__
from authlib.integrations.flask_client import OAuth
ModuleNotFoundError: No module named 'authlib'

I'm fairly new to docker itself. How do I go about resolving this?



Solution 1:[1]

In case anybody else comes across this, the solution was to add the Authlib module to the python env on the docker image.

The process for adding a new python module to the docker image is documented here: https://github.com/apache/superset/blob/master/docker/README.md#local-packages

Quoted below in case that file changes:

If you want to add python packages in order to test things like DBs locally, you can simply add a local requirements.txt (./docker/requirements-local.txt) and rebuild your docker stack.

Steps: 
1. Create ./docker/requirements-local.txt 
2. Add your new packages 
3. Rebuild docker-compose 
  a. docker-compose down -v 
  b. docker-compose up

Important was running docker-compose up and not docker-compose -f docker-compose-non-dev.yml up. The latter does not seem to rebuild the docker image.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user783836