SR12 bug: Message: 'module' object has no attribute '_'

A bug was discovered in SR12 (also affects Rhino for Mac 5.0.2 and earlier) yesterday that explains why some of you have started getting a “Message: ‘module’ object has no attribute ‘_’” error.

A script that looks like this:

   import rhinoscript.userinterface
   import rhinoscriptsyntax as rs

generates the error:

  "Message: 'module' object has no attribute 'GetLayer'"

What appears to be happening is that the 1st import loads the userinterface module so when the 2nd import statement runs the module is not reloaded and therefore the rs alias is not associated with functions in the userinterface module. The script works after deleting the 1st import and reseting the script engine so it looks like the explanation is correct.

But the above script works in SR11 which mean that the explanation is in fact incorrect. After some digging a bug was discovered in SR12 that causes this problem. The bug only manifests itself in scripts that have the line “import rhinoscript.userinterface” followed by the line “import rhinoscriptsyntax as rs” (‘rs’ or any other alias).

Even though the bug is in SR12 and not the script the solution is still to modify the script since in this context the 1st import doesn’t make sense. So to fix:

  • delete the import rhinoscript.userinterface line
  • restart the script engine or restart Rhino

I hope this helps and sorry for the confusion.


1 Like

I trust this newfound knowledge will allow you to include a very specific error message with suggested corrective action when this situation is detected?

If there’s a SR 13 I won’t include an error message but the fix that eliminates the problem.

G’day @Alain,

This still appears to be an issue.

I followed the instructions…

  • delete the import rhinoscript.userinterface line
  • restart the script engine or restart Rhino

but it appears “import rhinoscript.geometry” also needs to be removed before “import rhinoscriptsyntax as rs”. Removing userinterface alone was not enough to get mine to work.

Hi Ncik,

That’s right. Just don’t use any of the
import rhinoscript.userinterface import rhinoscript.geometry import rhinoscript.* ...
modules and just use
import rhinoscriptsyntax as rs