[Tutor] Problems importing random on linux

Adam adam at monkeez.org
Mon Apr 26 17:01:30 EDT 2004


orbitz at ezabel.com wrote:
> Sounds like you might have 2 version of python on your system.  Check for
> multiple python binaries.  also try running your script with: python
> autoguess.py and see what happens.
> 
> 
> On Mon, 26 Apr 2004 20:43:57 +0100
> Adam <adam at monkeez.org> wrote:
> 
> 
>>I use a linux machine and win machine at work. My win machine has no 
>>problem importing random and then using the randint(x,y) module. 
>>However, when I try and do this on my linux debian machine, I get:
>>
>>adam at debian:~/python$ ./autoguess.py
>>Traceback (most recent call last):
>>  File "./autoguess.py", line 49, in ?
>>    generatenumber()
>>  File "./autoguess.py", line 6, in generatenumber
>>    target = random.randint(0,100)
>>AttributeError: 'module' object has no attribute 'randint'
>>
>>from the code:
>>import random
>>
>>def generatenumber():
>>    target = random.randint(0,100)
>>
>>What is going on here? I've tried the same small piece of code :
>>import random
>>target = random.randing(0,100) at the interpreter and it works, but if I 
>>try this as an application in a file, it fails.
>>
>>Any ideas ?
>>
>>adam
>>

A 'which python' shows just one version in /usr/bin.

Running the command 'python autoguess.py' gives the same error.

I'm still puzzled.

Adam



More information about the Tutor mailing list