tikzexternalize works fine until I use the annotationimage environment (which itself doesn't work without disabling externalisation, for whatever reason):
\RequirePackage{mwe}
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz,pgfplots,tikz-imagelabels}
\usetikzlibrary{external}
\tikzexternalize[prefix=plot_]
\begin{document}
\tikzset{external/force remake}
\tikzsetnextfilename{01}
\begin{figure}[h]
\centering%
\begin{tikzpicture}%[trim axis left, trim axis right]
\begin{axis}
\addplot+ coordinates {%
(0,20)%
(60,-40)%
(150,-40)%
};%
\end{axis}
l \end{tikzpicture}%
\end{figure}
%\tikzset{external/export next = {false}}
%\begin{figure}
% \centering%
% \begin{annotationimage}{width = 4cm}{example-image-a}
% \draw[coordinate label = {Annotation at (0.2,0.2)}];
% \end{annotationimage}%
%\end{figure}
\end{document}
The log says system commands enabled (I am using --shell-scape).
If I uncomment the last part, I get the error below and the externalised PDF vanishes:
! Package tikz Error: Sorry, the system call 'lualatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "plot_01" "\def\tikzexternalrealjob{tikzex
ternalize}\input{tikzexternalize}"' did NOT result in a usable output file 'plo
t_01' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enab
led system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it
is also named 'write 18' or something like that. Or maybe the command simply fa
iled? Error messages can be found in 'plot_01.log'. If you continue now, I'll t
ry to typeset the picture.
Is this a bug, or am I missing something?
Just for context: I am using TeXstudio on Windows 10 with no admin rights. I installed TL2023 in my home folder (something like %userprofile%\stuff\texlive). I have to enter the path down to %userprofile%\stuff\texlive\2023\bin\windows in TeXstudio as search path for tikzexternalize to find lualatex.

\end{tikzpicture}and so the process fails. Disable externalization for this picture with e.g.\tikzexternaldisable. – Ulrike Fischer Oct 31 '23 at 13:41{\tikzexternaldisable …}it works. I thought I would be achieving the same by putting\tikzset{external/export next = {false}}before the figure environment. I took that from here: https://tikz.dev/library-external#sec-52.4.3. Should have read the part about\tikzexternaldisable, too … – ehak Oct 31 '23 at 17:52memoize.... – cfr Oct 31 '23 at 18:44