How to change Apache Airflow Python path from Python 2.7 to 3?

11,941

Solution 1

There are a few ways to make sure that you are using the version of Python that you would like. Docker is one, take a look at https://github.com/puckel/docker-airflow for a good example.

Another is to use virtual environments. I've only used Virtualenv with success. I like Pipenv, but unfortunately I ran into some dependency-trouble using it with Airflow.

Anyways, here is an example of what should work with Virtualenv:

cd your-project
virtualenv -p python3 .direnv
source .direnv/bin/activate
pip install -r requirements.txt

python --version should list python 3, and running airflow webserver, should run Airflow in python 3.

Solution 2

I had installed Apache Airflow and python 2.7 is set as default path.

Use

pip3 install apache-airflow

instead of

pip install apache-airflow
Share:
11,941
Raj
Author by

Raj

Updated on July 29, 2022

Comments

  • Raj
    Raj almost 2 years

    Initially, I had installed Apache Airflow and python 2.7 is set as default path. Now, I'm trying to change path from 2.7 to 3. Is it possible to do so or do I have re-install the airflow and set the python path? Any pointers would be helpful?

    Thanks in advance!