Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to resolve "Error: No module named 'airflow.www'" while starting airflow websever

Tags:

airflow

Getting below error while starting Airflow webserver

[email protected]:~$ airflow webserver -p 8080 [2018-12-03 00:29:37,066] {init.py:51} INFO - Using executor SequentialExecutor

[2018-12-03 00:29:38,776] {models.py:271} INFO - Filling up the DagBag from /Users/balajee/airflow/dags Running the Gunicorn Server with: Workers: 4 sync Host: 0.0.0.0:8080 Timeout: 120

Logfiles: - -

Error: No module named 'airflow.www'

like image 715
Balajee Avatar asked Dec 02 '18 19:12

Balajee


2 Answers

Fixed for me

pip3 uninstall -y gunicorn
pip3 install gunicorn==19.4.0
like image 103
lestat_kim Avatar answered Oct 02 '22 13:10

lestat_kim


I got this problem this morning, and I found a strange solution, may it helps you. I think maybe you just need to change the command running directory.
I install airflow basic dependence in my virtualenv directory venv with PyCharm help, and I use PyCharm build-in Terminal tab to directly access my venv, and I use airflow initdb to init sqlite database to store all my logs and ops, then according to the official tutorial I use airflow webserver to start the webserver. But somehow today I use my Mac terminal, and start virtulenv, and start airflow webserver, and I encounter this problem with:

Running the Gunicorn Server with:
Workers: 4 sync
Host: 0.0.0.0:8080
Timeout: 120
Logfiles: - -
=================================================================            

Error: No module named 'airflow.www'
[2019-05-26 07:45:27,130] {cli.py:833} ERROR - No response from gunicorn master within 120 seconds
[2019-05-26 07:45:27,130] {cli.py:834} ERROR - Shutting down webserver

And I tried @Evgeniy Sobolev's solution by reinstall gunicorn and nothing changed, but when I still using my PyCharm Terminal, it can still running successfully. I guess maybe it is because the first directory you init your db and running webserver is critical. By default when I use PyCharm Terminal to init db and start webserver is the Project root directory, like:

(venv) root@root:~/GitHub/FakeProject$ airflow webserver

But today I check into venv to start virtualenv, and the root directory changed!

root@root:~/GitHub/FakeProject/SubDir$ source venv/bin/activate 
(venv) root@root:~/GitHub/FakeProject/SubDir$ airflow webserver
** Error **

So in this way it encounters Error: No module named 'airflow.www', so I check out the directory, and the webserver running successfully just like PyCharm Terminal:

(venv) root@root:~/GitHub/FakeProject/SubDir$ cd ..
(venv) root@root:~/GitHub/FakeProject$ airflow webserver
** It works **

I thought maybe airflow store some metadata (like setup a PATH, maybe) in the first time init your airflow db, so you can not change your command running directory.
I hope it may help somebody in the future. Just check your directory!

like image 34
Ember Xu Avatar answered Oct 02 '22 12:10

Ember Xu