0

I am trying the below program, but getting Attribute error . Can someone help me solve this issue?

import random

print(random.randrange(1, 10))
Attribute error: partially initialized module 'random' has no attribute 'randrange'(most likely due to a circular import) 
Ram
  • 4,724
  • 2
  • 14
  • 22
  • Your code works for me. In your real code you haven't overridden the `random` module with a local variable called `random` have you? – DisappointedByUnaccountableMod Jul 26 '21 at 13:36
  • 2
    Is your own script named `random.py`? *That's* what would be found by `import random`, rather than the intended module. – jasonharper Jul 26 '21 at 13:36
  • Does this answer your question? [AttributeError: module 'random' has no attribute 'randint'](https://stackoverflow.com/questions/49599350/attributeerror-module-random-has-no-attribute-randint) – Gino Mempin Jul 26 '21 at 13:42
  • Does this answer your question? [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Peter O. Jul 26 '21 at 19:06

1 Answers1

2

Please check if you have named your file or srcipt as random.py , that is causing confusion with the random module .