0
0
AirflowHow-ToBeginner ยท 3 min read

How to Install Apache Airflow Using pip - Simple Steps

To install Apache Airflow using pip, run pip install apache-airflow in your terminal. This command downloads and installs Airflow and its dependencies in your Python environment.
๐Ÿ“

Syntax

The basic syntax to install Airflow using pip is:

  • pip install apache-airflow: Installs the latest stable version of Airflow.
  • You can specify a version like apache-airflow==2.7.1 to install a specific release.
  • Use pip install apache-airflow[extra] to add optional features like postgres or mysql.
bash
pip install apache-airflow
๐Ÿ’ป

Example

This example shows how to install the latest stable Apache Airflow version using pip in a terminal or command prompt.

bash
pip install apache-airflow
Output
Collecting apache-airflow Downloading apache_airflow-2.7.1-py3-none-any.whl (20 MB) Collecting ... (other dependencies) Successfully installed apache-airflow-2.7.1 ...
โš ๏ธ

Common Pitfalls

Common mistakes when installing Airflow with pip include:

  • Not using a virtual environment, which can cause package conflicts.
  • Installing without specifying extras needed for your database or executor.
  • Using an outdated pip version that may fail to resolve dependencies.

Always upgrade pip first with pip install --upgrade pip and use a virtual environment.

bash
pip install apache-airflow
# Wrong: No virtual environment, may cause conflicts

python -m venv airflow-env
source airflow-env/bin/activate  # On Windows use: airflow-env\Scripts\activate
pip install --upgrade pip
pip install apache-airflow[postgres]
# Right: Uses virtual environment and installs postgres extras
๐Ÿ“Š

Quick Reference

Summary tips for installing Airflow with pip:

  • Use a virtual environment to isolate packages.
  • Upgrade pip before installing.
  • Specify extras like [postgres] or [mysql] if needed.
  • Check Airflow's official documentation for version compatibility.
โœ…

Key Takeaways

Run pip install apache-airflow to install Airflow in your Python environment.
Always use a virtual environment to avoid package conflicts.
Upgrade pip before installation with pip install --upgrade pip.
Add extras like [postgres] if your Airflow setup requires them.
Check Airflow's official docs for the latest stable version and compatibility.