import error

C

cheeky

Hi, all.

I now really like to program with Python, even though I'm a newbie. I
have difficulty in solving the following problem.

$ python
Traceback (most recent call last):
File "x.py", line 6, in ?
import calendar, time
File "time.py", line 5, in ?
now = time.time()
TypeError: 'module' object is not callable

I now see the above error message. The source code is the following.

$ cat -n x.py
1 #!/usr/bin/python
2
3 import traceback
4
5 from datetime import date
6 import calendar, time

I don't have the line now = time.time() which encountered an error in
the previous step. I removed that line but I still see the error.

Someone says I should reload time module. However, I can't even import
time module. That's why I can't even try to reload time module name.

What's wrong with me? I'm studying on Ubuntu Linux. On Window IDLE
doesn't seem to have this problem. I saw someone saying it could be
happening when running independent script. I don't know what is right.

I really would like to know what is going on my system and how to clear
the past information. Thank you.
 
S

Simon Forman

cheeky said:
Hi, all.

I now really like to program with Python, even though I'm a newbie. I
have difficulty in solving the following problem.

$ python
Traceback (most recent call last):
File "x.py", line 6, in ?
import calendar, time
File "time.py", line 5, in ?
now = time.time()
TypeError: 'module' object is not callable

I now see the above error message. The source code is the following.

$ cat -n x.py
1 #!/usr/bin/python
2
3 import traceback
4
5 from datetime import date
6 import calendar, time

I don't have the line now = time.time() which encountered an error in
the previous step. I removed that line but I still see the error.

Someone says I should reload time module. However, I can't even import
time module. That's why I can't even try to reload time module name.

What's wrong with me? I'm studying on Ubuntu Linux. On Window IDLE
doesn't seem to have this problem. I saw someone saying it could be
happening when running independent script. I don't know what is right.

I really would like to know what is going on my system and how to clear
the past information. Thank you.

It looks like you might have a file named 'time.py' in the same
directory as your 'x.py'. If so, move it away (or rename it) and try
again.

HTH,
~Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

python import error 7
Distutils error 2
import serial failure 2
Cannot import cookies 0
unable to import rlcompleter readline 0
import problems. 0
import newer 0
import problem 5

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top