Interactive preview images failing

24 views
Skip to first unread message

Kyle Monette

unread,
Jul 8, 2026, 2:10:17 PMJul 8
to PreTeXt support
Hi all,

I noticed that preview images are not being generated for interactives in my book when building to a pdf document ("print"). Namely, jsxgraph images. I attempted the following command:
pretext generate -t print interactive

For some context -- I downloaded pretext on my Mac using pipx, and I'm using version 3.14 of Python. I have version 2.43.2 of Pretext (just upgraded today).

This appears to be an issue with Python 3.14. In particular, in the pretext/pretext/lib/pretext.py file, at line 1976 (linked here). According to some research, asyncio.get_event_loop() would implicitly create a new event loop in older Python versions if none existed in the current thread. This has since been deprecated.

The good news is that I have what appears to be a simple solution. Following the link above to the pretext.py file, one only needs to replace:
asyncio.get_event_loop().run_until_complete
with the following:
asyncio.run

Regretfully I don't have the confidence to submit an issue or PR to GitHub and have it actually be correctly done (and useful), for which I apologize. Learning Git has been on my bucket list :) 

- Kyle


Rob Beezer

unread,
Jul 8, 2026, 2:35:29 PMJul 8
to pretext...@googlegroups.com
Dear Kyle,

Will .run() behave with older versions of Python? In other words, when was it
first introduced?

It was only this week that we moved to 3.10 as the minimum Python version for
these routines.

(No, we are not opening a discussion about how old or how new 3.10 is, I know
exactly what the situation is.)

Rob

On 7/8/26 11:10, 'Kyle Monette' via PreTeXt support wrote:
> Hi all,
>
> I noticed that preview images are not being generated for interactives in my
> book when building to a pdf document ("print"). Namely, jsxgraph images. I
> attempted the following command:
> pretext generate -t print interactive
>
> For some context -- I downloaded pretext on my Mac using pipx, and I'm using
> version 3.14 of Python. I have version 2.43.2 of Pretext (just upgraded today).
>
> This appears to be an issue with Python 3.14. In particular, in the pretext/
> pretext/lib/pretext.py file, at line 1976 (linked here <https://github.com/
> PreTeXtBook/pretext/blob/e4dc1200082d23ceedd47f9cfa14f38d189a3cbb/pretext/lib/
> pretext.py#L1976>). According to some research, asyncio.get_event_loop() would
> implicitly create a new event loop in older Python versions if none existed in
> the current thread. This has since been deprecated.
>
> The good news is that I have what appears to be a simple solution. Following the
> link above to the pretext.py file, one only needs to replace:
> asyncio.get_event_loop().run_until_complete
> with the following:
> asyncio.run
>
> Regretfully I don't have the confidence to submit an issue or PR to GitHub and
> have it actually be correctly done (and useful), for which I apologize. Learning
> Git has been on my bucket list :)
>
> - Kyle
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/02a19363-f43b-49d0-8bf7-0f49ae364736n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/02a19363-
> f43b-49d0-8bf7-0f49ae364736n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Kyle Monette

unread,
Jul 8, 2026, 2:44:14 PMJul 8
to PreTeXt support
Hi Rob,

It seems it was added in version 3.7, according to this page

Rob Beezer

unread,
Jul 14, 2026, 3:51:00 PMJul 14
to pretext...@googlegroups.com
First, thank-you Kyle for the report, diagnosis, and suggested fix. There was
actually some code comments suggesting this needed to be done. Technical debt.

There was a second instance within a routine getting PDF images for MyOpenMath
problems. That was adjusted, too.

And my assistant suggested we could fail more gracefully for the interactive
preview images, so some work has gone into improving that situation.

https://github.com/PreTeXtBook/pretext/pull/3035

Rob


On 7/8/26 11:44, 'Kyle Monette' via PreTeXt support wrote:
> Hi Rob,
>
> It seems it was added in version 3.7, according to this page <https://
> docs.python.org/3/library/asyncio-runner.html#running-an-asyncio-program>.
>
> On Wednesday, July 8, 2026 at 2:35:29 PM UTC-4 Rob Beezer wrote:
>
> Dear Kyle,
>
> Will .run() behave with older versions of Python? In other words, when was it
> first introduced?
>
> It was only this week that we moved to 3.10 as the minimum Python version for
> these routines.
>
> (No, we are not opening a discussion about how old or how new 3.10 is, I know
> exactly what the situation is.)
>
> Rob
>
> On 7/8/26 11:10, 'Kyle Monette' via PreTeXt support wrote:
> > Hi all,
> >
> > I noticed that preview images are not being generated for interactives in my
> > book when building to a pdf document ("print"). Namely, jsxgraph images. I
> > attempted the following command:
> > pretext generate -t print interactive
> >
> > For some context -- I downloaded pretext on my Mac using pipx, and I'm using
> > version 3.14 of Python. I have version 2.43.2 of Pretext (just upgraded
> today).
> >
> > This appears to be an issue with Python 3.14. In particular, in the pretext/
> > pretext/lib/pretext.py file, at line 1976 (linked here <https://
> github.com/ <https://github.com/>
> > PreTeXtBook/pretext/blob/e4dc1200082d23ceedd47f9cfa14f38d189a3cbb/
> <https://groups.google.com/d/msgid/pretext->
> > support/02a19363-f43b-49d0-8bf7-0f49ae364736n%40googlegroups.com
> <http://40googlegroups.com> <https://
> > groups.google.com/d/msgid/pretext-support/02a19363- <http://
> groups.google.com/d/msgid/pretext-support/02a19363->
> > f43b-49d0-8bf7-0f49ae364736n%40googlegroups.com?
> utm_medium=email&utm_source=footer <http://40googlegroups.com?
> utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/5d4a5955-a839-4c49-bcf1-9947371158d8n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/5d4a5955-a839-4c49-
> bcf1-9947371158d8n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Reply all
Reply to author
Forward
0 new messages