Package listings error: numbers true unknown

Im getting a warning, as in tittle. Because of that (I think so) I cant see specified bacground colors and so on. Below I paste the source code. The error tells that it do not recognize the "true - how can I fix that?

\documentclass[final,3p,times]{elsarticle}


\pgfplotsset{compat=1.18}
\begin{document}

\textbf{Appendix: moving mesh}


\lstinputlisting[language=python, captionpos=t, label={ListingRecHEL1}]{data/code.py}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.6,0.9,0.1}
\renewcommand{\lstlistingname}{Kod}% Listing -> Algorithm
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{codepurple},
numberstyle=\tiny\color{codegray},
stringstyle=\color{orange},
basicstyle=\ttfamily\tiny,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
name = "Kod"
}
\lstset{style=mystyle}


\clearpage


\end{document}

Solution 1:

I have no clue what this documentclass is, so I used a KOMA class. Should have no effect on lstlisting. And mentioned in the comments, your example is not a working MWE, it is messed up with code that is not helpful to solve your issue.

The trick is simple: Just read the compilers messages. When it tells you, that there is an unknown option, you should try to remove it and compile again. numbers=true is not valid and not needed. Doc of listings

A working example that may come close to yours:

\documentclass[]{scrartcl}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{hyperref}

\begin{document}


\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.6,0.9,0.1}

\renewcommand{\lstlistingname}{Kod}% Listing -> Algorithm

\lstdefinestyle{mystyle}{
  backgroundcolor=\color{backcolour},
  commentstyle=\color{codegreen},
  keywordstyle=\color{codepurple},
  numberstyle=\tiny\color{codegray},
  stringstyle=\color{orange},
  basicstyle=\ttfamily\tiny,
  breakatwhitespace=false
  commentstyle=\color{codegreen},
  keywordstyle=\color{codepurple},
  numberstyle=\tiny\color{codegray},
  stringstyle=\color{orange},
  basicstyle=\ttfamily\tiny,
  breakatwhitespace=false,
  breaklines=true,
  captionpos=b,
  keepspaces=true,
  %numbers=true % <-----your tex compiler tells you that it is unknown
  numbers=left,
  numbersep=5pt,
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  tabsize=2,
  name = "Kod"
}


\lstinputlisting[
  language=python,
  style=mystyle,
  captionpos=t, 
  caption={My Python program}, 
  label={lst:promise}
  ]{code.py}

In \autoref{lst:promise} I did my very best.




\end{document}

The code.py:

def main():
    """This is a function"""
    return 'I will provide MWE when asking LaTeX related questions.'

# and this a line comment
if __name__=='__main__':
    print(main())

The result: enter image description here