I want to use tikzexternalize in my document, because the amount of tikz pictures is quite large. In general my tikz pictures are generated using matlab2tikz providing every tikz picture as a standalone. For the example the main document looks like this:
\documentclass{article}
\usepackage{standalone}
\usepackage{pgfplots}
\pgfplotsset{/pgf/number format/use comma}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
%
\begin{figure}
\centering
\includestandalone[width=0.8\linewidth]{./fig_01}
\caption{mycaption}
\label{fig:01}
\end{figure}
%
\end{document}
Within the file fig_01 the following simplified code was generated using matlab2tikz:
\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}
\begin{document}
%
\begin{tikzpicture}
\draw (2,2) ellipse (3cm and 1cm);
\end{tikzpicture}%
\end{document}
While excluding lines 7 and 8 from the main the compilation works fine - not so with the externalization activated.
My compilation command for pdflatex within TexStudio is:
"/usr/local/texlive/2015/bin/universal-darwin/pdflatex" -synctex=1 -interaction=nonstopmode %.tex
--shell-escapefor externalisation to work. – cfr Mar 29 '16 at 20:51