-1

I am trying to use random library in my VS code. This code is running well on Pycharm though. But I want to use VS Code anyway because it is less complicated. Below is my code

import random
number = random.randint(5,6)
print (number)

This is the error I'm getting.

from random import randint
ImportError: cannot import name 'randint' from partiaom.py", line 1, in <module>lly initialized module 'random' (most likely due to a circular import)
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

2 Answers2

1

Check any random.py or random.pyc file(which will override python random) in the current folder where ex43.py resides.If there, delete or rename that files.Also check import by

>>>import random
>>>print(random.__file__)

Check it is importing from packages

-1

I think many people make the same mistake I did. Creating a file called random.py and getting errors and trying to find the reason... Do NOT name the file random.py :) That was the lesson