+ 3

NEED HELP!!! AtributeError: module 'random' has no attribute 'randint'

When i use this simple code: import random random_number = random.randint(0,3) print(random_number) It raises this error: Traceback (most recent call last): File "random.py", line 1, in <module> import random File "C:\Users\Juampi\Desktop\Juampy\programacion\random.py", line 2, in <module> random_number = random.randint(0,3) AttributeError: module 'random' has no attribute 'randint' I've used the random module before and it worked properly, but now i tried and python raised that exception. If you go to https://docs.python.org/3.5/library/random.html (python random module page) you'll see 'random.randint' as an atribute in the module but when i try to use it it doesn't work. Please I need help guys.

5th Jan 2017, 8:31 PM
Juan Dieguez
Juan Dieguez - avatar
5 Respostas
+ 4
i had the same problem the first time I installed ipython,and i solved it reinstalling everything ^^` i'm sorry i can't help you more than this 😊
5th Jan 2017, 10:19 PM
Daniele Daini
Daniele Daini - avatar
+ 3
Really interesting problem and the solution is very easy.Just rename the file.like random_number.py If you want to know why this might help you. This error could be occuring because you have another module somewhere named random that your IDE is accessing instead of actually accessing the pe-included random module. This could be because you have another file named 'random.py'. If this is the case, rename the file to something else and the import should work fine. source: https://teamtreehouse.com/community/attributeerror-module-random-has-no-attribute-randint
25th Jan 2017, 9:22 AM
Abdullah Al Rafi
Abdullah Al Rafi - avatar
0
reinstall IDLE
5th Jan 2017, 8:35 PM
Maxim Kuzmin
Maxim Kuzmin - avatar
0
@Maxim Kuzmin nothing changed
5th Jan 2017, 8:38 PM
Juan Dieguez
Juan Dieguez - avatar