zivo zivo - 1 year ago 45
Python Question

Can't use sympy parser in my class; TypeError : 'module' object is not callable

I wrote some code for calculating the differential equation and it's solution using sympy, but I'm getting an error, my code : ( example )

from sympy.parsing import sympy_parser

I get

TypeError: 'module' object is not callable

What am I doing wrong here ?

Answer Source

sympy_parser is a module, and modules are not a callable. What you want is sympy_parser.parse_expr:

>>> from sympy.parsing import sympy_parser
>>> r ='3/2'
>>> r = sympy_parser.parse_expr(r)
>>> r