Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk3 min

How to Fix “ModuleNotFoundError: No module named keras.utils.vis_utils” in Python

Replace the unavailable keras.utils.vis_utils import with the public plot_model utility from the same Keras API family used to build your model.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For current standalone Keras, import plot_model from keras.utils, not the unavailable keras.utils.vis_utils submodule:

from keras.utils import plot_model

plot_model(model, to_file="model.png", show_shapes=True)

If your model was created with TensorFlow’s Keras API, use from tensorflow.keras.utils import plot_model instead. Keep the import in the same API family that created the model.

As an Amazon Associate I earn from qualifying purchases.

Choose the import that matches your model

The error means Python cannot find the requested keras.utils.vis_utils module in the active environment. Use the public utility import for the Keras package your code already uses; do not assume that the old submodule exists in every Keras or TensorFlow release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Your code builds the model with Import to use When this route fits
Standalone Keras from keras.utils import plot_model The current Keras API documents keras.utils.plot_model. See Keras model plotting utilities.
TensorFlow Keras from tensorflow.keras.utils import plot_model Use TensorFlow’s namespace when the model is built through tensorflow.keras. The Keras 2 reference documents the corresponding public legacy API as tf_keras.utils.plot_model. See Keras 2 model plotting utilities.

For example, keep a TensorFlow Keras model and plotting utility together:

from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.utils import plot_model

model = Sequential([Dense(8, input_shape=(4,))])
plot_model(model, to_file="model.png", show_shapes=True)

Likewise, use the standalone keras namespace consistently if that is how the model was created. Keras 3 describes standalone Keras and TensorFlow’s Keras API as separate packages, not APIs to mix side by side; see the Keras 3 announcement.

Check the Python environment running your code

A correct import can still fail if the command-line Python, installed packages, and notebook kernel do not refer to the same environment. Check the Keras version from the same interpreter or notebook that produced the exception:

import keras
print(keras.__version__)

Keras documents this version check in its setup instructions. Before installing or changing anything, confirm that your python and pip commands target that environment. For notebooks, verify the active kernel rather than relying on a separate terminal’s package list.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Replace the old import without switching to internals

Change code that imports from keras.utils.vis_utils to the matching public import shown above. Avoid substituting a private path such as keras.src: internal namespaces are not stable interfaces, and the Keras migration guide explains the transition from TensorFlow-only Keras 2 code to multi-backend Keras 3.

If the import works but saving the diagram fails

Importing plot_model and rendering a diagram are separate steps. If the import succeeds but the call to plot_model(...) raises an ImportError, check that Graphviz and pydot are installed and visible to the same Python environment. Keras 2’s plotting reference lists missing Graphviz or pydot as an ImportError condition. Installing those rendering dependencies does not make an unavailable keras.utils.vis_utils module importable.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When to keep a legacy Keras 2 setup

If an older application depends on Keras 2 behavior, evaluate the documented compatibility options rather than changing packages blindly. Keras documents using the tf_keras package with TensorFlow and setting TF_USE_LEGACY_KERAS=1 before launching Python; the setup guide covers the configuration. Confirm the project’s TensorFlow, Keras, and dependency constraints before adopting either route. For maintained code that does not require Keras 2 compatibility, use the public import supported by the package version in use.

Quick troubleshooting checklist

  • Identify whether the model is created with standalone keras or tensorflow.keras.
  • Import plot_model from that same package family’s public utils namespace.
  • Check the installed Keras version in the exact interpreter or notebook kernel raising the error.
  • If only diagram rendering fails, investigate Graphviz and pydot separately from the import error.
  • Use the legacy Keras 2 options only when compatibility requirements call for them.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.