I wrote a very simple python program.
#!/usr/bin/env python
import random
x = random.uniform(-1, 1)
print str(x)
I run this from command prompt.
python random.py
It returned with error:
Traceback (most recent call last):
File "random.py", line 2, in <module>
import random
File "D:\python practise\random.py", line 3, in <module>
x = random.uniform(-1, 1)
AttributeError: 'module' object has no attribute 'uniform'
It is a very simple program, I can't understand what mistake I did in this.
(operating system: Windows 7; python version: 2.7)
#!usr/bin/env pythonis not necessary; it does absolutely nothing. That's for Unix-like OSes so that the shell can know how to run the script