Search code examples
pythonfunctionmodulewing-ide

Why are some of the functions missing when I call a module I created from another script?


I'm working with a module I created a while ago, where I have a bunch of functions I keep re-using. Today, I added a new one but when I try to call it from another script, I got the error "AttributeError: 'module' object has no attribute NameOfMyFunction".

The way I'm calling the functions is like this:

import sys
sys.path.append("C:/temp/Volpe_Final_Project/ReUsable")
import GRHE_proj  as GRHE
output=GRHE.TimeDeltaToTime(data)

My module "GRHE_proj" has several functions, as you can see in this screenshot (I'm using WingWare): !https://i.sstatic.net/Duwme.png

But when I import the module in my other script I only get 3 options: !https://i.sstatic.net/KIllG.png

Any ideas of why some of the functions are being omitted?


Solution

  • It looks like you are not importing the module you think you are. Print GRHE_proj.__file__ to see what you got. When you are importing a module that is not in the standard library path, it's generally better to insert your path at the front of the list instead of appending it to the back so that you don't risk importing a different version of the module that is in the path.

    import sys
    sys.path.insert(0, "C:/temp/Volpe_Final_Project/ReUsable")
    import GRHE_proj  as GRHE
    output=GRHE.TimeDeltaToTime(data)