"import random" suddenly stopped working.

Asked by Azkan

I'll be honest here and say that I know practically nothing about Python or Java, and I only tried out Sikuli because I figured that its features are more appropriate for achieving my goals.

I needed some random numbers, so I put this at the top of my code:
import random
random.seed()

I went and tested my code and everything worked perfectly. I was quite pleased. This was a couple of hours ago.

Now, whenever I try to Run, I get this error on the "import random" line:
ImportError: Errors in loading sikuli module: random
'module' object has no attribute 'seed'
 - HOW TO FIX? Try adding "from sikuli import *" in the module.

I have no idea why a totally new error would pop up when I had not made any changes in my previously working code.

Any help would be greatly appreciated.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

this usually happens if you have a .sikuli script with the same name as an imported module in the same folder as the running script.

In your case, I guess, there is random.sikuli in the folder or even the running script has this name.

One rule in Sikuli (since importing .sikuli scripts has precedence):
Do not have scripts named xxx.sikuli in the same folder as the running script or on sys.path, where xxx is the name of a normal Python module, you want to import.

Take care: when renaming xxx.sikuli to xxxzzz.sikuli: either use File -> SaveAs or take care, that the contained .py file has the same name as the script (xxxzzz.py in this case)

Can you help with this problem?

Provide an answer of your own, or ask Azkan for more information if necessary.

To post a message you must log in.