Re: I can't import random module


Alex Earl
 

Do you have the StdLib added to your path? random.py is in the Python stdlib and it imports the _random module from IronPython.Modules. Without the stdlib, you can't import random.


On Wed, Sep 30, 2020 at 7:31 AM <javierfernandezc@...> wrote:
I have already seen that, thanks. I tried that and failed againg:

clr.AddReferenceByName('IronPython.Modules')
from IronPython.Modules import *
import random
foo = ['a', 'b', 'c', 'd', 'e']
print(random.choice(foo))  

ERROR: No module named random



Join users@ironpython.groups.io to automatically receive all group messages.