在Windows10运行的Ubuntu20.04环境中安装Airflow 2.1.4遭遇Errno 2文件不存在错误的解决咨询
Let’s work through this error step by step—your hunch about pip might not be the whole story, so let’s start with the most likely fixes first:
1. Fix the Syntax Error in Your Installation Command
Looking at the command you shared, it’s missing a closing double quote at the end of the --constraint argument. This is a common shell parsing issue that can confuse pip into looking for an empty-named requirements file.
Your original command cuts off prematurely:
--constraint "${CONSTRAINT_URL}
Correct the full command (split into lines for readability):
AIRFLOW_VERSION=2.1.4 PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)" CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt" pip3 install "apache-airflow[async,postgres,google,amazon,ssh,sftp]==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
2. Verify the Constraint URL Is Valid
Sometimes the auto-generated CONSTRAINT_URL might fail if your Python version parsing doesn’t work as expected. Let’s confirm:
- Run this command alone to check your parsed Python version:
For Ubuntu 20.04, this should returnpython3 --version | cut -d " " -f 2 | cut -d "." -f 1-23.8(the default Python 3 version). - Check if the constraint file exists by running:
You should see acurl -I "https://raw.githubusercontent.com/apache/airflow/constraints-2.1.4/constraints-3.8.txt"200 OKresponse if the file is valid. Airflow 2.1.4 supports Python 3.6-3.9, so 3.8 is a valid match.
3. Upgrade pip to the Latest Version
Older pip versions can have compatibility issues with modern package constraint files. Update pip with:
sudo pip3 install --upgrade pip
After upgrading, re-run your corrected installation command.
4. Use a Virtual Environment (Recommended)
Using sudo with pip can mess up your system Python environment and cause permission conflicts. Instead, create an isolated virtual environment for Airflow:
# Create a virtual environment python3 -m venv airflow-env # Activate the environment source airflow-env/bin/activate # Run your corrected Airflow installation command inside this environment
This keeps your system packages clean and avoids unexpected errors.
5. Manually Download the Constraint File (If Network Issues Occur)
If you’re blocked from fetching the remote constraint file due to network restrictions, download it locally first:
wget https://raw.githubusercontent.com/apache/airflow/constraints-2.1.4/constraints-3.8.txt
Then install Airflow using the local file:
pip3 install "apache-airflow[async,postgres,google,amazon,ssh,sftp]==2.1.4" --constraint ./constraints-3.8.txt
内容的提问来源于stack exchange,提问作者Hedieh Moradi

