I’ve had a similar issue before trying to import random. One thing I noticed in your code is that you’re importing from Python 3, but I think Dynamo uses IronPython 2.7. I’m not sure if this makes a difference, but it might be something to pay attention to.
I found my solution in a post like this one:
Cant import random module to Python
That post includes the code used to path to the IronPython modules.