You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "dosubot[bot] (via GitHub)" <gi...@apache.org> on 2025/07/31 11:28:10 UTC
Re: [I] ModuleNotFoundError and MyCustomclass which is derived from IndexView in superset_config.py [superset]
dosubot[bot] commented on issue #34422:
URL: https://github.com/apache/superset/issues/34422#issuecomment-3139567401
<!-- Answer -->
This error usually happens because Superset only imports uppercase attributes from superset_config.py into its main config module, so classes like MyCustomclass (not all uppercase) won’t be accessible as attributes of the superset_config module itself. This is by design in recent Superset versions, including 5.0.0, and is handled in the config loader logic [source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/config.py).
To use a custom IndexView, define your class at the top level of superset_config.py, then reference it using its full module path as a string in the relevant config variable (e.g., `FAB_INDEX_VIEW = 'superset_config.MyCustomclass'`). Here’s an example pattern:
```python
from flask_appbuilder import IndexView
class MyCustomclass(IndexView):
# your overrides here
FAB_INDEX_VIEW = f"{MyCustomclass.__module__}.{MyCustomclass.__name__}"
```
[supporting example](https://github.com/apache/superset/discussions/18571)
Make sure superset_config.py is in your PYTHONPATH or set the SUPERSET_CONFIG_PATH environment variable to its location, and restart Superset after changes. If you’re running in Docker Compose, place your config at `/app/docker/pythonpath_dev/superset_config_docker.py` [source](https://github.com/apache/superset/discussions/25487).
If you still get the AttributeError, double-check for typos, ensure the class is defined at the top level (not inside a function or conditional), and review logs for import errors. Only uppercase variables are imported into the main config, but classes can still be referenced by their module path as shown above.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2357061e-99af-4b9a-9f95-e2902698b3ed?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=githu
b) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/34422)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org