[Python] why is maya failing to import my python libarary and run a function defined within it

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    my library is saved at C:\Users\user1\Documents\maya\scripts\test_lib.py, and its entire content is:

    def my_func():
    print("hello world!")


    when I run the following in the script editor, I get an error:

    import test_lib
    my_func()
    # Error: NameError: name 'my_func' is not defined


    I did restart Maya to make sure the changes were picked up, yet the error persists. I dont understand what is causing this issue, I have other libraries and scripts in the same script folder and they import just fine, some example files in my script folder:

    C:\Users\user1\Documents\maya\scripts\test_lib.py
    C:\Users\user1\Documents\maya\scripts\grid_fill.py
    C:\Users\user1\Documents\maya\scripts\userSetup.py
    C:\Users\user1\Documents\maya\scripts\component.py
    C:\Users\user1\Documents\maya\scripts\quickMat.mel
    ...


    Running just the import grid_fill in the script will successfully import grid_fill.py, and running its corresponding functions does not give me a "not defined" error.

    What could this be down to? Am on Maya 2026

    Continue reading...

Compartilhe esta Página