Sahil Babbar
Sahil Babbar

Reputation: 143

AttributeError: 'module' object has no attribute 'TextCalendar'

When I copy the below code in Ideone then it runs fine but it is not running in the text editor and showing the error mentioned in the subject of this post:

import calendar   
c = calendar.TextCalendar(calendar.SUNDAY)
c.prmonth(2007, 7)

The complete error is:

Traceback (most recent call last):
  File "calendar.py", line 1, in <module>
    import calendar   
  File "/home/shl/Desktop/calendar.py", line 2, in <module>
    c = calendar.TextCalendar(calendar.SUNDAY)
AttributeError: 'module' object has no attribute 'TextCalendar'

Upvotes: 0

Views: 4308

Answers (1)

ravi507
ravi507

Reputation: 81

change the program name from calendar.py to something like calendar_code.py

This wold work properly.

Importing from builtin library when module with same name exists

Upvotes: 8

Related Questions