Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my import time give error module object is not callable

Tags:

python

time

I just want to use the import time function to get a timestamp from python.

import time

I have this sample test code which works just fine on cloud 9.

import time
now = int(time.time() * 1000)
print now

But it doesn't work on my mac. I get an error right on line 1.

Python 2.7.11 (default, Mar 21 2016, 23:21:56) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "time.py", line 2, in <module>
    now = int(time.time() * 1000)
TypeError: 'module' object is not callable
>>> 

Not sure what is going on here it is frustrating.

like image 264
Matsu Thornton Avatar asked Dec 07 '25 08:12

Matsu Thornton


1 Answers

You have a file in your local directory called "time.py". Rename it.

like image 57
Daniel Roseman Avatar answered Dec 09 '25 21:12

Daniel Roseman