airflow dag import error: ModuleNotFoundError: No module named 'snowflake'
Fixes a DAG import error where the Snowflake provider package is missing from the environment that parses the DAG. Use when a DAG using SnowflakeOperator or the snowflake hook fails to load. Not for Snowflake connection or credential failures inside a running task.
TL;DR
The DAG file imports a snowflake module, usually through SnowflakeOperator or SnowflakeHook, but the apache-airflow-providers-snowflake package is not installed in the Python environment doing the parsing. Install the provider that matches your Airflow version into the scheduler and every worker, restart the parsing processes, and confirm with airflow dags list-import-errors. Installing snowflake-connector-python alone is not enough, because the operator classes live in the provider package.
airflow dag import error: ModuleNotFoundError: No module named 'snowflake'Use this when
- The Airflow UI shows an import error naming the snowflake module for a DAG that uses Snowflake operators.
- airflow dags list-import-errors reports ModuleNotFoundError for the same file.
- The DAG loaded before an image rebuild, a requirements change, or an Airflow upgrade.
Not for this skill when
- The DAG loads and the task fails on authentication or network access to Snowflake. That is a connection problem.
- Your own code imports a local helper named snowflake. Rename it or fix the Python path instead.
Steps
- Find the exact import: run airflow dags list-import-errors and note the file and line that import snowflake. Note whether it is SnowflakeOperator, SnowflakeHook, or a plain connector import. Verify: you know which package the import actually needs
- Check what is installed in the parsing environment with pip show apache-airflow-providers-snowflake and pip show snowflake-connector-python. Note which one is missing. Verify: the missing package is identified, not guessed
- Install the provider version compatible with your Airflow release, using your constraints file, into the scheduler, webserver, and worker images or virtualenvs. Note the pinned version in requirements. Verify: every component that parses or runs the DAG has the same provider
- Restart the scheduler and workers so the DAG processor picks up the new package, then rerun airflow dags list-import-errors. Note the snowflake error is gone. Verify: the import error list no longer contains this DAG
- Trigger a test run of one Snowflake task and confirm it reaches the connection stage instead of failing at import. Note the task log shows a connection attempt. Verify: import is fixed and any remaining failure is a separate connection issue
Variant phrasings
airflow No module named snowflake provider not installed
The package-shaped search for the same missing provider.
ModuleNotFoundError snowflake in airflow dag file
The raw interpreter error, without the Airflow framing.
Compatibility: Airflow 2.x with the Snowflake provider package; also applies on Airflow 3 where providers are installed separately from core. Managed services need the provider added through their requirements or image build, not a live pip install.
Why it happens
Airflow core ships almost no vendor code. Each integration lives in its own provider package, which depends on the vendor client library. A DAG that imports SnowflakeOperator therefore needs two layers present, the provider and snowflake-connector-python, in every environment that parses or executes it. Image rebuilds and constraint upgrades routinely drop one layer, and the failure appears at parse time, before any task runs, which is why the whole DAG vanishes from the UI instead of one task failing.
Edge cases / pitfalls
- The scheduler parses fine but Celery or Kubernetes workers fail the same way. Their images diverged; build all of them from one requirements set.
- A constraints file for a different Airflow version can silently pin an incompatible provider. Regenerate constraints for your exact Airflow version.
- Do not fix this by wrapping the import in a try block. The DAG will load and then fail confusingly at run time.
- In KubernetesExecutor, the fix belongs in the worker pod image, not only in the scheduler deployment.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Su6CJEmGe1A5DDOAK8so-Q