I'm trying out the solution in : Lstlisting Python

but in Beamer.

And no matter what I write, it throws me like a thousand errors:

enter image description here

I thoroughly checked. There is no missing }

My code is literally (after I have all the correct packages as indicated in the url above)

\begin{frame} \begin{lstlisting}    do nothing. \end{lstlisting} \end{frame}

can someone produce a minimal working example so I can try to replicate?

Btw I have no luck with minted because I'm missing some pygm package.

1 Answer 1


You need to add fragile option to frame:

\lstset{basicstyle=\ttfamily, keywordstyle=\bfseries}

\begin{frame}[fragile] % <---
\frametitle{Example of \texttt{listings} code}

if x==0:


enter image description here

  • 1
    Thanks. Fragile seems to be the silver bullet in 99% of these mysterious errors.
    – Olórin
    Commented Feb 16, 2021 at 1:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .