By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

AttributeError: 'module' object has no attribute 'randint'

P: 8
i am a beginner, i tried to have python generate a random integer from 0 to 10
my code looks like this:

import random
number = random.randint(0,10)
print number

i am using python 2.7
it gives AttributeError: 'module' object has no attribute 'randint'

please help, thank you very much.
Oct 22 '11 #1

✓ answered by bvdet

I'll take a guess. You have anther file named "random.py" on the Python path that is read before the random module is reached.

Share this Question
Share on Google+
5 Replies


Expert 100+
P: 621
My guess is that "random" is misspelled in the original code. We don't have the complete error message so there is no way to tell anything really.
Oct 23 '11 #2

bvdet
Expert Mod 2.5K+
P: 2,851
I'll take a guess. You have anther file named "random.py" on the Python path that is read before the random module is reached.
Oct 23 '11 #3

Expert 100+
P: 621
And we've all done that so I usually add "test" to any program names when testing a module, "random_test1.py".
Oct 26 '11 #4

P: 8
Thanks bvdet and dwblas, in my python path there was another random.py file which was being read before the random module.

Thank you all.
Oct 29 '11 #5

P: 8
I am sorry for this nonrelated post, but can someone kick fgjtydger out of the forum because i dont know how.
Oct 29 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Browse more Python Questions on Bytes