Python Forum

Full Version: Pycharm Import statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello -
Hoping this is the right forum.
I installed pycharm and started using it. I am running into an error when using the import statement. Can you please let me know what I need to do to resolve the below error. Thank you for your help in advance.

My code
import random
print(random.randint())
Error

Error:
"C:\Users\108167\PycharmProjects\Project 1\venv\Scripts\python.exe" "C:/Users/108167/PycharmProjects/Project 1/venv/random.py" Traceback (most recent call last): File "C:/Users/108167/PycharmProjects/Project 1/venv/random.py", line 1, in <module> import random File "C:\Users\108167\PycharmProjects\Project 1\venv\random.py", line 2, in <module> print(random.randint()) AttributeError: module 'random' has no attribute 'randint'
don't name your file random.py. This way you shadow the built-in module with the same name.