Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 奇怪的名称错误:名称';数学';未定义,而;“导入数学”;_Python_Math_Python 3.x_Nameerror - Fatal编程技术网

Python 奇怪的名称错误:名称';数学';未定义,而;“导入数学”;

Python 奇怪的名称错误:名称';数学';未定义,而;“导入数学”;,python,math,python-3.x,nameerror,Python,Math,Python 3.x,Nameerror,我在执行此代码时收到NameError。这很奇怪,因为代码中有导入数学。西格玛模块中有重要的数学知识……也许这是一种冲突? 谢谢你的时间 File "C:\Users\Greenman\Documents\Python Scripts\sigma_crit.py", line 21, in sigma_crit # Simplified MC NameError: name 'math' is not defined 您正在运行过时的字节码。您更改了源文件,但没有重新启动Pyt

我在执行此代码时收到NameError。这很奇怪,因为代码中有导入数学。西格玛模块中有重要的数学知识……也许这是一种冲突? 谢谢你的时间

  File "C:\Users\Greenman\Documents\Python Scripts\sigma_crit.py", line 21, in sigma_crit
    # Simplified MC

NameError: name 'math' is not defined

您正在运行过时的字节码。您更改了源文件,但没有重新启动Python

你可以从回溯中看到这一点;回溯是通过读取源文件并从正在运行的字节码中获取嵌入的行号信息来生成的,以显示源代码中的对应行


但是你的回溯会在下一行显示评论;字节码引用显然已经过时,并且您在之后更改了代码。

投票赞成包含回溯,回溯包含答案;-)非常欢迎你……:)
import sigma as sgm # Module sigma has "import math" as well
import math
def sigma_crit(sigmaX, sigmaY, sigmaZ, Theta, Pw, Pres, nu, alpha, No):
    """
    Return value of critical stress calculated for one of three failure criterias.
    No: 1 - Simplified Mohr-Coulomb
        2 - Mohr-Coulomb
        3 - Drucker-Prager
        4 - list with 3 model's resutls
    sigmaX - stress at X wellbore axis
    sigmaY - stress at Y wellbore axis
    Theta - azimuth,anticlokwise from SH_max
    nu - Poisson's ratio
    alpha - Biot's  coefficient
    """ 
    sigma_theta = sgm.sigma_calc(sigmaX, sigmaY, sigmaZ, Theta, Pw, Pres, nu, alpha, 1)
    sigma_zi = sgm.sigma_calc(sigmaX, sigmaY, sigmaZ, Theta, Pw, Pres, nu, alpha, 2)
    sigma_thzi = sgm.sigma_calc(sigmaX, sigmaY, sigmaZ, Theta, Pw, Pres, nu, alpha,3)
    # Conerting degrees to radians for below equations...Caution above functions has built-in converter
    Theta = math.radians(Theta)
    # Simplified MC