Reputation: 2614
I'm baffled as to why the command line isn't able to run a certain script when the Python GUI can. What i'm trying to run is:
import random
print random.random()
Which runs fine in the Python GUI but when saved as a file (random.py) and ran through the command line
C:\Users\Name>python c:\Python\random.py
it produces this error:
TypeError: 'module' object is not callable
Has anyone had this problem or know why it occurs?
Thanks for your time!
Upvotes: 1
Views: 367
Reputation: 59974
This is because you have overridden the actual module random
by creating your own random.py
. Now, you're importing your own file which you're trying to call, and not actually importing the module which has the random
function.
To fix this you need to do two things:
Rename your file to something other than random.py
Get rid of the .pyc
created as a result of importing.
Upvotes: 8