How to Fix “Cannot Import Name ‘Pivot’ from ‘Scripts’” ImportError in MEL/Python

If you’ve been trying to install Matt Taylor’s mtTools script in Autodesk Maya and got smacked with an error that looks like this:

# Error: ImportError: file C:/Users/antza/OneDrive/Documents/maya/2022/scripts\mtTools\mtTools.py line 36: 
cannot import name 'Pivot' from 'Scripts' (unknown location) #

I feel your pain I ran into the exact same issue, and it had me scratching my head for quite a while.

The Code I Was Running

Here’s the original launch code I used inside Maya’s Script Editor:

import importlib
import sys
import os

sys.path.append(os.environ['USERPROFILE'] + '/Documents/maya/scripts/mtTools/')
import mtTools.mtTools as mtTools
importlib.reload(mtTools)
mtTools.showUI()
mtTools.shelf.Start()  # Remove this line if you don't want the shelf

Running that should normally load the UI but instead it exploded with the ImportError.

What’s Breaking It

Inside mtTools.py, there’s a line like this:

from Scripts import Pivot

This is where things go wrong.

Maya is trying to import a module called Pivot from a folder called Scripts, but Python can’t find it.

There are only three possible reasons:

CauseExplanation
Missing fileThere’s no Pivot.py in your scripts/Scripts/ folder
Wrong pathThe Scripts folder exists but isn’t in Python’s sys.path
Wrong filenameFile exists but is named lowercase like pivot.py instead of Pivot.py

Once I figured that out, fixing it became easy.

Check if Pivot.py Exists

Go to your Maya scripts directory:

C:\Users\<YourName>\OneDrive\Documents\maya\2022\scripts\

Inside that folder, manually check if there’s a subfolder called Scripts, and inside it, a file named Pivot.py.

  • If it doesn’t exist, you need to copy or download it from the script package.
  • If it exists but it’s named pivot.py, rename it to Pivot.py (Python is case-sensitive on import!).

Manually Add the Folder to Python’s Import Path

This is what I ended up doing and it worked perfectly.

import importlib
import sys
import os

scripts_dir = os.environ['USERPROFILE'] + '/Documents/maya/2022/scripts/'
mttools_dir = scripts_dir + 'mtTools/'

sys.path.append(scripts_dir)    # Add main Scripts folder
sys.path.append(mttools_dir)    # Add mtTools folder

import mtTools.mtTools as mtTools
importlib.reload(mtTools)
mtTools.showUI()
mtTools.shelf.Start()

Now Maya knows where to look when it sees from Scripts import Pivot.

I Added a Quick Test Function to Validate Imports

Before launching the UI, I like to run this little helper:

def test_import(module_name):
    try:
        __import__(module_name)
        print(f"Successfully imported {module_name}")
    except ImportError as e:
        print(f"Failed to import {module_name}: {e}")

# Test modules before launching UI
test_import("mtTools.mtTools")
test_import("Pivot")  # Test if Pivot is importable

If both imports pass, I know I can safely launch the tool.

Final Thought

This kind of ImportError might look scary, but it usually comes down to one simple thing: Python doesn’t know where a file is. Once I understood that, fixing the issue became much easier. Now mtTools works perfectly, the shelf loads fine, and I can finally get back to animating instead of debugging. If you’re still stuck, just drop a comment with your folder structure I’ll gladly help you troubleshoot.

Related blog posts