执行此代码时收到NameError。这很奇怪,因为代码中有导入数学。 sigma模块中有导入数学...也许它有点冲突? 谢谢你的时间!
File "C:\Users\Greenman\Documents\Python Scripts\sigma_crit.py", line 21, in sigma_crit
# Simplified MC
NameError: name 'math' is not defined
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
答案 0 :(得分:3)
您正在运行陈旧的字节码。您更改了源文件,但没有重新启动Python。
你可以从追溯中看到这个;通过读取源文件并从正在运行的字节码中获取嵌入的行号信息来生成回溯,以显示源中的相应行。
但你的追溯显示了对 next 行的评论;字节码引用显然已经过时了,你改变了代码。