You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Windows10运行的Ubuntu20.04环境中安装Airflow 2.1.4遭遇Errno 2文件不存在错误的解决咨询

Troubleshooting "Could not open requirements file" Error When Installing Airflow 2.1.4 on WSL Ubuntu 20.04

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:
    python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2
    
    For Ubuntu 20.04, this should return 3.8 (the default Python 3 version).
  • Check if the constraint file exists by running:
    curl -I "https://raw.githubusercontent.com/apache/airflow/constraints-2.1.4/constraints-3.8.txt"
    
    You should see a 200 OK response 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.

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 18:52:46