'Is there a way to obtain the same LaTeX output as one gets in Jupyter, but in Visual Studio?

For some unbeknownst reason which I have not been able to identify, and I already proposed in the form of my first programming question, I can not get the results as smoothly as I previously could in Jupyter notebook and the only result is a "Busy Kernel". The same result occurs when the same code is run in Spyder. I was wondering is there a way to produce this result in Visual Studio 2022? Because when I run the Python code integrated with LaTeX in Visual Studio, no observable difference can be seen between print() function and display() function. Here is the code:

 x = 7
 y = -2
 z = 5

 ans = 3*x*(4+y)

 display(Math( '3x(4+y)=%g' %ans))
 display(Math( '3\\times %g(4+%g)=%g' %(x,y,ans)))
 ans2 = -y - (x+3)/z
 display(Math( '-y-\\frac{x+3}{z}=%g' %ans2 ))
 display(Math( '-%g-\\frac{%g+3}{%g}=%g' %(y,x,z,ans2) ))


Solution 1:[1]

I recognize that example, because just now I am following the same Udemy course. For the exercises in the course I am not using Visual Studio, but the Jupyter extension for VS Code, and the output is the nice expected Latex one. Did you remember to load the display and Math functions before?

from IPython.display import display, Math

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BFir