As the PyCrypto API says, the IV must be a byte string, not a text string.
Your piece of code will work fine in Python 2, because they are the same thing (that is, they all are class str, unless you deal with Unicode text). In Python 3 they are two completely different types: bytes and str.
The code should therefore be:
iv = bytes([ random.randint(0,0xFF) for i in range(16)] ) Such code (beside not being cryptographically secure as Federico points out) will not properly work in Python 2 though. The following alternative works fine in both cases, it is secure and it is more efficient:
iv = Random.new().read(16)