Skip to content

Commit 2df92a8

Browse files
authored
Limit version of IPython to < 9.17.0 to avoid import error during notebook validation (#1118)
Some of the notebooks use Kera's `plot_model` function. That function has a check for whether graphviz is installed. If it is _not_ installed, `plot_model` then tests whether "IPython.core.magics.namespace" is present in `sys.modules` and does one of two things: if it's present, `plot_model` prints a message; if it is not present, it raises an `ImportError`. Unfortunately, starting in IPython 9.17.0, IPython no longer eagerly imports `IPython.core.magics.*` modules at startup. Unless Graphviz is installed separately in the run-time environment, calling `plot_model` will raise an `ImportError`. Our notebook checks are done using our script `ci_validate_tutorials.sh`, and that script pip-installs IPython, but it only sets a lower bound on the version number. As a result, when the script executes in CI, it installs a version of IPython >= 9.17.0, which leads `plot_model` to fail the test for "IPython.core.magics.namespace", which leads it to raise `ImportError` in CI. The simplest solution is to add an upper bound on the version number in `ci_validate_tutorials.sh`, which is what this PR does. This will solve the CI failures and also help any users who may encounter the same problem when testing notebooks locally.
1 parent 9e378d1 commit 2df92a8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎scripts/ci_validate_tutorials.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export TF_USE_LEGACY_KERAS=1
2323
pip install \
2424
"nbclient==0.6.5" \
2525
"jupyter-client==7.4.9" \
26-
"ipython>=8.10.0" \
26+
"ipython>=8.10.0,<9.17.0" \
2727
"ipykernel>=6.29.0"
2828

2929
# Gymnasium pip package needed for the quantum reinforcement learning tutorial

0 commit comments

Comments
 (0)