I am trying to include an unknown amount of image files with unknown file names in a document. My code is inspired by a comment on this answer: https://tex.stackexchange.com/a/53465/206040
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{pythontex}
\begin{document}
Pictures:
\begin{pycode}
import os
directory = "".""
extension = ".png"
files = [file for file in os.listdir(directory) if file.lower().endswith(extension)]
for file in files:
print r"\begin{figure}[!ht]"
print r"\centering"
print r"\includegraphics[width=10cm,height=10cm]{%s}" % file
print r"\caption{File %s}" % file
print r"\label{Serie}"
print r"\end{figure}"
\end{pycode}
\end{document}
The code is working but the images are not included in my pdf. How do I solve this or is there a better / easier way to do this?
By the way: I've wanted to use the pythontex package as it does not require using the --enable-write18 option? But I also don't know if there is an even better way.

--shell-escapeflag during compilation? This flag has to be set as TeX requires shell access in order to interact with Python.--enable-write18is just a similar thing. – Alan Xiang Dec 26 '20 at 00:39txs:///pdflatex,txs:///pdflatex --shell-escape, andtxs:///pdflatex --enable-write18in TexStudio as compilation commands. It runs fine, but the images are not included in my pdf file. – owmal Dec 27 '20 at 10:18