无法在自制模块

时间:2016-02-03 13:13:49

标签: python import module importerror

我有以下代码:

colour_profile.py

import numpy as np

def n_BK7(wavelength):
    B1 = 1.03961212
    B2 = 0.231792344
    B3 = 1.01046945
    C1 = 6.0069867e-3
    C2 = 2.00179144e-2
    C3 = 1.03560653e2
    return np.sqrt(1+B1*wavelength**2/(wavelength**2-C1) + \
    B2*wavelength**2/(wavelength**2-C2) + B3*wavelength**2/(wavelength**2-C3))

def n_Flint(wavelength):
    B1 = 1.34533359
    B2 = 0.209073176
    B3 = 0.937357162
    C1 = 0.00997743871
    C2 = 0.0470450767
    C3 = 111.886764
    return np.sqrt(1+B1*wavelength**2/(wavelength**2-C1) + \
    B2*wavelength**2/(wavelength**2-C2) + B3*wavelength**2/(wavelength**2-C3))

main.py

import numpy as np
import numpy.linalg as npl
import draw_3d_test_rotate as r2
import time
from colour_profile import n_BK7, n_Flint

我不断获得ImportError: cannot import name n_Flint,但我确实设法导入了n_BK7。我尝试在colour_profile.py中交换n_BK7和n_Flint排列的顺序。我尝试交换它们导入的顺序,将from colour_profile import n_BK7, n_Flint分成两个单独的导入行,但它们都不起作用。为什么?我只能导入其中一个函数的功能有什么特别之处?

1 个答案:

答案 0 :(得分:2)

PYTHONPATH环境变量中的内容是什么?

似乎另一个colour_profile.py不包含n_Flint函数