superset: ModuleNotFoundError: No module named 'sqlglot' error across many containers
Bug description
Working on a 2023 Macbook Air M2
I followed the steps per wiki here https://superset.apache.org/docs/installation/installing-superset-using-docker-compose/ (which I believe needs updating) and I am unable to have stable build for many containers under the main superset container.
- Cannot reach
http://localhost:8088/. Page is blank. - Error I am getting below.
Skipping local overrides
Starting web app (using development server)...
Skipping local overrides
Starting web app (using development server)...
Skipping local overrides
Starting web app (using development server)...
<jemalloc>: MADV_DONTNEED does not work (memset will be used instead)
<jemalloc>: (This is the expected behaviour if you are running under QEMU)
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: While importing 'superset.app', an ImportError was raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 218, in locate_app
__import__(module_name)
File "/app/superset/__init__.py", line 21, in <module>
from superset.app import create_app
File "/app/superset/app.py", line 24, in <module>
from superset.initialization import SupersetAppInitializer
File "/app/superset/initialization/__init__.py", line 35, in <module>
from superset.extensions import (
File "/app/superset/extensions/__init__.py", line 30, in <module>
from superset.async_events.async_query_manager import AsyncQueryManager
File "/app/superset/async_events/async_query_manager.py", line 26, in <module>
from superset.utils.core import get_user_id
File "/app/superset/utils/core.py", line 90, in <module>
from superset.sql_parse import sanitize_clause
File "/app/superset/sql_parse.py", line 29, in <module>
from sqlglot import exp, parse, parse_one
ModuleNotFoundError: No module named 'sqlglot'
This error above is looping endlessly
How to reproduce the bug
- git clone https://github.com/apache/superset.git
- cd superset
open docker-compose.yml- paste
platform: linux/x86_64/v8under each superset container - Please include in your wiki for arm64 users, as this will save folks a lot of time.
Eg
superset:
platform: linux/x86_64/v8
...
superset-websocket:
platform: linux/amd64
...
superset-init:
platform: linux/x86_64/v8
...
superset-node:
platform: linux/x86_64/v8
...
superset-worker:
platform: linux/x86_64/v8
...
superset-worker-beat:
platform: linux/x86_64/v8
...
superset-tests-worker:
platform: linux/x86_64/v8
- run
docker compose up --build -d - Notice the
ModuleNotFoundError
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.9
Node version
18 or greater
Browser
Chrome
Additional context
No response
Checklist
- I have searched Superset docs and Slack and didn’t find a solution to my problem.
- I have searched the GitHub issue tracker and didn’t find a similar bug report.
- I have checked Superset’s logs for errors and if I found a relevant Python stacktrace, I included it here as text in the “additional context” section.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 49 (18 by maintainers)
Same goes for me and I have done exactly the same steps. Trying to push this in my company but is hard when the local thing just doesn’t works …
@SbstnErhrdt Thanks for your reply. You did not specify what machine you are using.
platform: linux/x86_64/v8in the docker file of each container?superset-websocketnow?superset_config.pyfile and export its path to mysupersetdir so that the app reads it and override the secret key that is weak by default.tag_3.1.0, I get a new log error forsuperset-websocketthat says its looking for aconfig.jsonfile now?? when its clearly usingconfig.pyfor configurationI resolved the issues by checking out the latest stable release
My system:
Steps
If all runs smoothly
Quick note that we met with the devx sub-team and I said I’d pick up doing a set of improvements for the docker-compose workflows addressing the core issues here. Main idea is referencing the branch’s Dockerfile as opposed to a baked image like we do now.
Hi, You might want to install it yourself (by editing to
.superset/docker/requirements-local.txt).This dependency was cherry picked and added to master, how ever you all still using outdated images. (For example me who use based on 3.1.0 multiplatform docker image.)
Cheers
I found one more error with postgres container where it is looking for a test table which does not exist. What I did is added CREATE DATABASE test command in ./docker/examples-init.sh. And tried again. I am still in the process to confirm if the UI opens up or not.
My two containers are down even after the module fix:
2024-02-08 16:45:28 2024-02-08 11:15:28,136:ERROR:flask_appbuilder.security.sqla.manager:DB Creation and initialization failed: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: Connection refused 2024-02-08 16:45:28 Is the server running on that host and accepting TCP/IP connections? 2024-02-08 16:45:28 connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: database "test" does not existAlso, I am not able to login with username: admin and password: adminNeed help to make this working.
The config.json file issue with WebSocket is in the master also. It’s not just related to tags/3.1.0. The solution for ModuleNotFoundError, for now, is to create a requirements-local.txt in
./docker pathand put this sqlglot==20.8.0. Then if you run docker-compose again, you will not find this error. @yashagv @vikramwalia @ricokali96 @andrekef@rusackas We are missing the dependency in the docker-image being used by the docker-compose. The image seems to be old and does not have the additional changes of base.txt. This needs to be fixed.
same issue on Amazon x86-64 EC2 instance with Ubuntu
Quite true! You can tell when master breaks as people come flooding into Slack reporting the same problem. But I don’t think using new users as test subjects is probably good for the long-term health of the project. I expect for every person who reports a GitHub issue about broken master branch, many more give up silently and say Superset is not ready for production.
I will put it on the town hall list, good idea.
Digging a bit into this, I understand some things, but I’m not 100% clear on how this is setting or exactly how things are supposed to work here. But few things I know
docker-compose.yml has this ->
Which points to
latest-devwhich right now is3.1.0which does not havesqlglot. So if yougit checkout 3.1.0you candocker-compose upand things line up.Pointing to
master-devseems more appropriate and much more likely to work, but if you’re on arm we don’t build that particular variation on these days.With this PR -> https://github.com/apache/superset/pull/27146 we’ll be having multi-platform build for master, so that would make things work better.
Though I’m not sure what’s a normal setup for docker-compose here and how the repo is supposed to line up with the images. My best bet is recent master should work on top of a recent image build off of master (as in the master-dev tag), but that seems fragile, there’s no guarantee that any particular SHA should match the latest image. I guess if you have a freshly rebases branch and we have a fresh image, things should line up most of the time.
Thanks @akshayjain3450 Resolved ‘sqlglot’ error after adding sqlglot==20.8.0.
All containers are up, but “http://localhost:8088/superset/welcome/” is continuously loading. When I did port forwarding, it shows me favicon icon. http://localhost:8089/static/assets/images/favicon.png Also not able to connect 5432 database.
Are you able to run, Can you suggest something?
Are we looking for any update soon on this.
not resolved yet ! what [SbstnErhrdt] said does not work for me.
Pinging @betodealmeida and @john-bodley since it sounds related to their recent consolidation efforts.