from __future__ import division
import math
from sympy import *
d=symbol('d')
x=solve(d**2 - 224*d + 400)
print(x)
Hi,I'm new to python.I just tried to solve a polynomial expression using symPy,but got the following error.
Traceback (most recent call last):
File "C:/Windows/System32/test.py", line 4, in <module>
d=symbol('d')
TypeError: 'module' object is not callable
Someone pls help me out with the correct function.Thank you
You're sure you are running python3, and your script is not named something that conflicts with any other modules? Do you have a file named sympy.py in your script's directory? (You shouldn't)
I never use import *, you never know what kind of namespace errors you'll run into. This code works 100% for me:
#!/usr/bin/env python3
import math
import sympy
d = sympy.Symbol('d')
x = sympy.solve(d**2 - 224*d + 400)
print(x) # Prints [-4*sqrt(759) + 112, 4*sqrt(759) + 112]
x = sympy.solve(d - 10)
print(x) # Prints 10
capitalize Symbol and try again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With