求问python求解定积分
我用这个方法求解定积分,之前尝试成功过,突然就报错NameError,请问大神们是怎么回事呢?from sympy import *
x = symbols('x')
print(integrate(x, (x, 1, 2)))
然后会报下面错误
D:\python\python.exe D:/python/Python_Documents/HProject/稳定计算/位移计算.py
Traceback (most recent call last):
File "D:/python/Python_Documents/HProject/稳定计算/位移计算.py", line 1, in <module>
from sympy import *
File "D:\python\lib\site-packages\sympy\__init__.py", line 22, in <module>
import mpmath
File "D:\python\lib\site-packages\mpmath\__init__.py", line 5, in <module>
from .ctx_fp import FPContext
File "D:\python\lib\site-packages\mpmath\ctx_fp.py", line 1, in <module>
from .ctx_base import StandardBaseContext
File "D:\python\lib\site-packages\mpmath\ctx_base.py", line 10, in <module>
from .calculus.optimization import OptimizationMethods
File "D:\python\lib\site-packages\mpmath\calculus\optimization.py", line 3, in <module>
from copy import copy
File "D:\python\Python_Documents\HProject\稳定计算\copy.py", line 2, in <module>
x = symbols('x')
NameError: name 'symbols' is not defined
Process finished with exit code 1
不知道啊,我机器上这段代码是好的{:10_245:} 多了个括号还是少了个 你的源代码不要命名为copy.py,换个名字 d:\wp>py
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> x = symbols('x')
>>> print(integrate(x, (x, 1, 2)))
3/2
>>> hrp 发表于 2021-3-2 07:14
你的源代码不要命名为copy.py,换个名字
感谢,解决了
页:
[1]