Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Maya python, unexpected indent

Maya python, unexpected indent

Anonymous
Not applicable
1,446 Views
3 Replies
Message 1 of 4

Maya python, unexpected indent

Anonymous
Not applicable

Hi

So I'm following an online course on Udemy for Python Coding for Maya, I've written out the code the same as the instructor (per the image), I've followed everything in the video. And it doesn't work, I keep getting "# Error: IndentationError: file <maya console> line 2: unexpected indent #" This is driving me mad. Why is this happening?

Python_Indent_Problem.jpg

0 Likes
1,447 Views
3 Replies
Replies (3)
Message 2 of 4

stuzzz
Collaborator
Collaborator

hello, Please make sure you have 4 spaces instead of tab as a indentation.

Is there a space right before "from maya import cmds" ?

Try to delete the first empty line

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hey

 

No, there are no spaces. However, I have tried it with spaces and it still doens't work. I'll try your suggestions of 4 spaces instead of a tab.

 

Thanks

0 Likes
Message 4 of 4

stuzzz
Collaborator
Collaborator

ok I got it.

Your function is indented for no reason it has to have the same indentation as "from maya import cmds"