I need to convert strings with valid python syntax such as:
\'1+2**(x+y)\'
and get the equivalent LaTeX:
$1+2^{x+y}$
You can use SymPy. Just pass the string to the sympify() function first, which will convert it to a valid SymPy expression (i.e., create the Symbols for you, etc.). So you could do
>>> latex(sympify('1+2**(x+y)'))
1 + 2^{x + y}
S() is also a shortcut to sympify(), i.e., latex(S('1+2**(x+y)')) also works.