Airflow安装后命令无法运行求助(Python3.6.8环境)
Hey there, I’ve dealt with this exact issue before—let’s break down what’s wrong and get your Airflow setup working properly.
What’s Causing the Error?
The root problem is a Python version mismatch in your installation constraints. You’re running Python 3.6.8, but you installed Airflow using a constraints file built for Python 3.7. Even though the install didn’t show errors, this mismatch led to an incomplete installation: the airflow executable script wasn’t properly registered or installed in your environment, which is why pkg_resources can’t find it.
Step-by-Step Fix
Let’s clean up the broken install and do it the right way:
Uninstall the broken Airflow instance
First, remove the existing Apache Airflow package to start fresh:pip uninstall -y apache-airflowFor extra safety, you can check your Python site-packages directory (like
/Users/a13220361/airflow_final/lib/python3.6/site-packages/) and delete any remainingapache_airfloworapache_airflow-1.10.12.dist-infofolders to eliminate leftover files that might cause conflicts.Reinstall Airflow with the correct constraints file
Airflow 1.10.12 has dedicated constraints files for different Python versions. Since you’re on Python 3.6.8, you need to use the constraints file designed for Python 3.6 (not 3.7). Adjust your install command to swap outconstraints-3.7.txtwithconstraints-3.6.txtin the constraint path, then run the command again.Verify the installation
Once the reinstall finishes, test if Airflow works by running:airflow versionYou should see the Airflow 1.10.12 version number printed without any errors if everything went right.
Why This Works
Using the constraints file matched to your Python version ensures all dependencies Airflow requires are fully compatible with Python 3.6.8. This fixes the underlying issue where the airflow script wasn’t properly set up during the initial installation.
内容的提问来源于stack exchange,提问作者Mukesh

