Skip to main content

Fixed: "Could not import graphviz. Rendering graph to the graphical format will not be possible." in Apache Airflow®

· 8 min read
Jagdish Kumawat
Founder @ Dewiride

Every airflow dags command I ran in Apache Airflow® 3.4.0 printed a three-line warning: Could not import graphviz. Rendering graph to the graphical format will not be possible. It appeared even for commands that never draw a graph. Here's where it comes from, the one package that ends it, and why Airflow's graphviz extra doesn't help on a Mac.

What I Was Doing​

I had installed Airflow 3.4.0 with uv on Python 3.14, using Airflow's constraints file and no extras. With the project's virtual environment active and AIRFLOW_HOME set, I checked whether any Dag file had failed to load:

Terminal
airflow dags list-import-errors

What I Expected​

No data found, because every Dag file loaded.

What I Got​

No data found, after a warning about a package called graphviz:

Output (excerpt)
2026-12-04T10:46:13.912254Z [warning ] Could not import graphviz. Rendering graph to the graphical format will not be possible.
You might need to install the graphviz package and necessary system packages.
Run `pip install graphviz` to attempt to install it. [py.warnings] category=UserWarning filename=.../site-packages/airflow/cli/commands/dag_command.py lineno=57
No data found

The terminal after airflow dags list-import-errors: the UserWarning Could not import graphviz. Rendering graph to the graphical format will not be possible., with the advice to run pip install graphviz, from dag_command.py line 57, then No data found.

The full output also starts with two FileType is deprecated warnings, which I left out here; Fixed: FileType is deprecated explains them. Every other airflow dags command printed the graphviz warning too.

What I Checked​

What graphviz is. Graphviz is a tool for drawing graphs, and graphviz is the Python package that describes graphs for it. Airflow uses it to draw a Dag's tasks and their dependencies.

Where the warning comes from. It's raised in airflow/utils/dot_renderer.py, the module that draws Dags. When the module is loaded, it tries import graphviz, and if that fails it warns and carries on without it:

airflow/utils/dot_renderer.py (Airflow 3.4.0, excerpt)
if TYPE_CHECKING:
import graphviz
...
else:
try:
import graphviz
except ImportError:
warnings.warn(
"Could not import graphviz. Rendering graph to the graphical format will not be possible. \n"
"You might need to install the graphviz package and necessary system packages.\n"
"Run `pip install graphviz` to attempt to install it.",
UserWarning,
stacklevel=2,
)
graphviz = None

TYPE_CHECKING is true only for tools that check type hints, so when Airflow runs, the else part is the one that runs. stacklevel=2 makes the warning name the line that loaded the module: line 57 of dag_command.py, the file behind every airflow dags command. So every one of those commands loads dot_renderer and prints the warning, whether it draws anything or not.

Which commands need it. Only three use the drawing code: airflow dags show, airflow dags show-dependencies, and airflow dags test with one of its --show-dagrun, --imgcat-dagrun or --save-dagrun options. Without graphviz, airflow dags show stopped with an error and exit code 1:

Output (excerpt)
airflow.sdk.exceptions.AirflowException: Could not import graphviz. Install the graphviz python package to fix this error.

Why the extra doesn't help on a Mac. Airflow has a graphviz extra, but its package metadata only asks for graphviz on systems other than macOS:

apache_airflow_core-3.4.0.dist-info/METADATA (excerpt)
Requires-Dist: graphviz>=0.20; (sys_platform != 'darwin') and extra == 'graphviz'

sys_platform is darwin on macOS, so apache-airflow[graphviz] installs no graphviz there.

Upstream. I reported the warning on every command as apache/airflow#77850. The fix, apache/airflow#77852, stops the warning on commands that don't draw. It's merged, and its 3.4 copy, apache/airflow#77962, is too, both under the milestone Airflow 3.4.1. On 2026-12-04, the newest release on PyPI was still 3.4.0.

Why It Happens​

Airflow 3.4.0 loads its graph-drawing module for every airflow dags command, and that module warns as soon as the graphviz Python package is missing. A constraints-file install without extras doesn't include it, and on macOS the graphviz extra doesn't either.

The Fix​

Install the graphviz Python package into Airflow's virtual environment, with the same constraints file you installed Airflow with:

Terminal
uv pip install graphviz --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-3.4.0/constraints-3.14.txt"
Output
Resolved 1 package in 635ms
Prepared 1 package in 98ms
Installed 1 package in 2ms
+ graphviz==0.21

The terminal after uv pip install graphviz with Airflow's constraints file: Resolved 1 package, Prepared 1 package, Installed 1 package, and + graphviz==0.21.

  • uv pip install graphviz installs the package into the active virtual environment.
  • --constraint points uv at Airflow's tested versions for Airflow 3.4.0 on Python 3.14, so it picks graphviz==0.21, the version that file lists. For another Python version, use the file for that version, the same one you installed Airflow with.

If you don't need the drawing commands, you can also leave the warning alone: it's harmless for the other commands, and the upstream fix is set for Airflow 3.4.1.

After the Fix​

I ran the same command, then asked Airflow to describe a Dag's graph:

Terminal
airflow dags list-import-errors
airflow dags show make_breakfast
Output (excerpt)
No data found
digraph make_breakfast {
graph [label=make_breakfast labelloc=t rankdir=LR]
boil_water [color="#000000" fillcolor="#ffefeb" label=boil_water shape=rectangle style="filled,rounded"]
brew_tea [color="#000000" fillcolor="#ffefeb" label=brew_tea shape=rectangle style="filled,rounded"]
serve [color="#000000" fillcolor="#ffefeb" label=serve shape=rectangle style="filled,rounded"]
toast_bread [color="#000000" fillcolor="#ffefeb" label=toast_bread shape=rectangle style="filled,rounded"]
boil_water -> brew_tea
boil_water -> toast_bread
brew_tea -> serve
toast_bread -> serve
}

The terminal after the install: airflow dags list-import-errors prints only No data found, and airflow dags show make_breakfast prints the Dag as a digraph with its four tasks and the lines between them.

The graphviz warning is gone, and airflow dags show, which failed before, now prints the Dag in DOT, Graphviz's text format for graphs: one line per task, and one -> line per dependency.

Common Mistakes​

MistakeWhat happensDo this instead
Installing apache-airflow[graphviz] on macOSNo graphviz: the extra only applies when sys_platform != 'darwin'Install graphviz itself
Installing graphviz without the constraints fileYou can get a version Airflow 3.4.0 wasn't tested withPass the same --constraint URL as for Airflow
Installing it outside the virtual environmentAirflow still can't import it, and the warning staysActivate the project's .venv first

Troubleshooting​

SymptomLikely causeFix
Could not import graphviz. Install the graphviz python package to fix this error. from airflow dags showgraphviz isn't installed in Airflow's environmentInstall it as in The Fix
The warning stays after the installThe package went into another environmentRun the install with Airflow's .venv active

FAQ​

Do I need graphviz at all?​

Only for the commands that draw a Dag: airflow dags show, airflow dags show-dependencies and the drawing options of airflow dags test. The UI draws its own graphs and doesn't use it.

Is the warning harmful?​

No. Commands that don't draw work normally: airflow dags list-import-errors printed its answer right after it.

Conclusion​

Could not import graphviz came from Airflow 3.4.0's graph-drawing module, which every airflow dags command loads, warning whenever the graphviz Python package is missing. uv pip install graphviz with Airflow's constraints file installed graphviz==0.21, ended the warning, and made airflow dags show work. Airflow 3.4.1 will stop the warning on commands that don't draw.

Additional Resources​

Apache®, Apache Airflow and Airflow® are either registered trademarks or trademarks of The Apache Software Foundation in the United States and/or other countries. No endorsement by The Apache Software Foundation is implied by the use of these marks.