Importing MathJax or anvil.tables

Hi, I am pretty new to anvil, therefore I am not familiar with all the packages and what is required to import them. I am currently looking for a way to display LaTex on my app.

So I need to import mathJax. However “from anvil.js.window import MathJax” gives me “AttributeError: ‘Window’ object has no attribute ‘MathJax’”. Then I found an app I could clone which uses

from ._anvil_designer import Form1Template
from anvil import *
import plotly.graph_objects as go
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
from anvil.js.window import MathJax

at the beginning. This app works fine for me, but when I copy this code to my app and replace the “Form1Template” with the name of my Form. It doesnt work for me and I get “ModuleNotFoundError: No module named ‘anvil.tables’” from the following code at the top of my app:

from ._anvil_designer import RechungenTemplate
from anvil import *
import math
import re 
from anvil.js.window import navigator

import plotly.graph_objects as go
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
from anvil.js.window import MathJax

Is it possible that this error occurs because I dont have the paid version? Or is there another explainantion I am overlooking?

Thanks in advance to anyone who can help me or provide me with some tips!

Welcome to the forum!

Can you post a clone link of your original app that had the AttributeError? That’ll help folks work out what’s wrong with it.

Sure, I hope I copied the correct link :).

https://anvil.works/build#clone:46N53G2MBNSW37HZ=E7I3TGKQOWHC4NQF7KWGU4SD

The displayed text in the app is German and some variables have German names too, but I guess the text is irrelelvant for my question, so it shouldn’t be a problem.

I don’t see any uses of MathJax in that app. Can you point me to where you have the MathJax import?

Assuming that you have that import somewhere, it would be failing because you don’t have anything in your Native Libraries section to import MathJax. According to the MathJax documentation, you’d need this in your Native Libraries section:

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
2 Likes

Yeah, I had not written the MathJax-part, because then the app would not be useable and quite some people need to use it.

Thanks a lot for the tip with the Native Libraries. I had no idea, that I needed a code like that in a place like that (as I didnt even know it existed). I have now implemented the part I wanted to display with LaTex and everything works perfectly.

1 Like