python – Sagemath as daemon service – name ‘e’ is not defined”

I have been using Sagemath as a daemon service following the Python code presented here:

ask.sagemath.org/question/23431/running-sage-from-other-languages-with-higher-performance/

That code sets up Sagemath as a daemon service using python sockets

I make sockets calls via php sockets to connect with this sagemath daemon, and it works fine, except that it does not recognize the constant ‘e’, while it does recognize ‘pi’.

For example, if I run simplify(4*pi^2*pi^3) through the socket call, it will do the algebra correctly, whereas if I run simplify(4*pi^2*pi^3*e), it returns the error:

“ERROR: <class ‘NameError’> name ‘e’ is not defined”

From what I have gathered, when run this way Sagemath will need to import libraries explicitly. The imports in the python daemon are:

import sys
from io import StringIO
from sage.all import *
from sage.calculus.predefined import x
from sage.repl.preparse import preparse

Any hints?
Thanks!

Read more here: Source link