Synctex is not working with pyluatex (using latexmk in TeXworks, MiKTeX, Windows 10)

forward-inverse-searchlatexmkmiktexpyluatextexworks

I have recently started to experiment with the pyluatex package (which lets you include Python 3 code in a .tex document, and have it run during the .tex compilation process).

https://www.ctan.org/pkg/pyluatex

I have a setup that I am pretty happy with, except that I haven't gotten synctex (forward-inverse-search) to work. My documents compile properly and I do get proper .pdf output; the only problem is that I also get a synctex(busy) file (so of course Ctrl-click in the source or the output doesn't do anything).

Here is a minimal example where synctex doesn't work:

\documentclass{article}
\usepackage[executable=python.exe]{pyluatex}
\begin{document}

Hello

\end{document}

It would not surprise me if my question is related to this one. However, please note that synctex works properly if I do not use pyluatex. For example, the following document compiles and produces a .pdf and a synctex.gz file, and synctex seems to work just fine:

\documentclass{article}
%\usepackage[executable=python.exe]{pyluatex}
\begin{document}

Hello

\end{document}

In case it is relevant, I am using Windows 10, with TeXworks (0.6.6) and MiKTeX (21.12.10), and I am using the following typesetting options (available from the Edit, Preferences, Typesetting menu in TeXworks):

Program:

latexmk

Arguments:

-lualatex
--synctex=1
--shell-escape
$fullname

(Latexmk seems to be version 4.76.)

I guess the question is: Why is synctex not working for me? In other words, am I doing something wrong (perhaps with the Typesetting options I am using)? Or maybe I have installed something wrong, or need to update something. Please let me know if there is further information that I should have provided.

Best Answer

It turned out that the problem is a PyLuaTeX bug under Windows. Since the Python interpreter was not shut down early enough in previous versions of PyLuaTeX, the SyncTeX output file was locked and could not be finished (i.e., compressed and renamed) properly.

It has been fixed in the new version 0.4.1 https://github.com/tndrle/PyLuaTeX/commit/86725935425f2d4e879efba4227744df807c675e

Related Question