Physicist
Physicist

Reputation: 3058

Unable to import some functions in a self-made module

I have the following codes:

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

I keep getting ImportError: cannot import name n_Flint, but I do manage to import n_BK7. I tried exchanging the order that n_BK7 and n_Flint are arranged in colour_profile.py. I tried exchanging the order they are imported, separating from colour_profile import n_BK7, n_Flint into two separate import lines, but none of them work. Why? What's so special about the functions that I can only import one of them?

Upvotes: 1

Views: 76

Answers (1)

mvelay
mvelay

Reputation: 1520

What's in your PYTHONPATH environment variable ?

It seems there is another colour_profile.py elsewhere that does not contain n_Flint function

Upvotes: 2

Related Questions