0

I'm typing this code :

import calendar

cal = calendar.month(2014, 7)
print(cal)

I don't know whats the problem is or where i got spelling mistakes. It just keeps giving me this error:

AttributeError: 'module' object has no attribute 'month'
3
  • Does this work for you in Python2? Commented Jul 30, 2014 at 14:56
  • @kirelagin: it works just fine in Python 3. Provided you are not masking the library, that is. Commented Jul 30, 2014 at 14:58
  • @MartijnPieters Sure it does. Commented Jul 30, 2014 at 14:59

1 Answer 1

10

In all likelihood you have a local file calendar.py that is imported instead of the module in the standard library.

Find out where by printing the module:

import calendar
print(calendar)

Rename that file, it is masking the standard library version.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.