How do you use the random.randint function for variables?

How do you do this with out it resulting in a error?

import random




I’m guessing you are getting the “No module named random” error. If so, you need to install Python. Your code works well with Python installed, both in command line and as Blender script.

The explanation is: Blender Python does not have its own random library. The random library is one of Python standard libraries. You only get it once you installed the standard Python distribution on your machine.

If you don’t want to install Python, you can use the Blender Mathutils library, it has a Rand function to return a random number between the low and high values:

from Blender import Mathutils

@ Da Krazy Jak - Frankly, I tested your supplied code “as is” in Blender 2.49b and there’s been NO error in the result(s)! I guess it will run OK in 2.5x too cause it is a rather general code (I havent tested this yet).

May be you need to supply more info about your problem - which Blender version you use, if Python is installed properly, add CODE-/CODE tags to your supplied code, publich a copy of console screen with the error message you receive…


Thanks SnifiX your right that did work.