Python Forum
Pycharm Import statement - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pycharm Import statement (/thread-18220.html)



Pycharm Import statement - sunilramakumar - May-09-2019

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'



RE: Pycharm Import statement - buran - May-09-2019

don't name your file random.py. This way you shadow the built-in module with the same name.