Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache airflow: No module name 'airflow' [closed]

Tags:

python

airflow

I am new to apache airflow and I am following the example code at: https://github.com/apache/airflow/blob/master/airflow/example_dags/tutorial.py

I copied and pasted the code found in the link above in an example.py inside a folder on my desktop.

The initial code is:

from airflow import DAG
from airflow.operators.bash_operator import BashOperator

If I run python example.py, I get the error:

from airflow import DAG

ModuleNotFoundError: No module named 'airflow'

Even if I installed airflow as follows:

pip install apache-airflow

What can be a possible solution?

like image 371
Magofoco Avatar asked Aug 24 '19 15:08

Magofoco


People also ask

How do I add Python modules to my Airflow project?

add your modules to one of the folders that Airflow automatically adds to PYTHONPATH package your code into a Python package and install it together with Airflow. The next chapter has a general description of how Python loads packages and modules, and dives deeper into the specifics of each of the three possibilities above.

Why is my airflow/operators subfolder not accessible?

For example if you create airflow/operators subfolder it will not be accessible because Airflow already has a package named airflow.operators and it will look there when importing from airflow.operators. Never use relative imports (starting with .) that were added in Python 3.

What is the default username and password for airflow?

# Default: apache/airflow:master-python3.8 # AIRFLOW_UID - User ID in Airflow containers # Default: 50000 # AIRFLOW_GID - Group ID in Airflow containers # Default: 50000 # _AIRFLOW_WWW_USER_USERNAME - Username for the administrator account. # Default: airflow # _AIRFLOW_WWW_USER_PASSWORD - Password for the administrator account.

How to configure the plugins folder in airflow 2?

The plugins Folder: It is configured with option plugins_folder in section [core]. The DAGS folder in Airflow 2 should not be shared with the webserver. While you can do it, unlike in Airflow 1.10, Airflow has no expectations that the DAGS folder is present in the webserver.


1 Answers

Running:

pip install \
 apache-airflow==1.10.10 \
 --constraint \
        https://raw.githubusercontent.com/apache/airflow/1.10.10/requirements/requirements-python3.7.txt

Worked for me. Check here: https://airflow.apache.org/docs/stable/installation.html

like image 138
Michael Gee Avatar answered Oct 04 '22 09:10

Michael Gee