Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying a calendar
#1
I've been trying to display a calendar month using Python3.6 and whilst the code works perfect from the command-line it only produces a list of errors if i try to display from a file in Atom text editor. Hope someone can help please.

#!/usr/bin/env python3.6 

# import module
import calendar

yy = 2018
mm = 11

# To ask month and year from the user
# yy = int(input("Enter year: "))
# mm = int(input("Enter month: "))

# display the calendar
print(calendar.month(yy, mm))
Reply
#2
(Jul-08-2018, 10:06 AM)oldDog Wrote: it only produces a list of errors if i try to display from a file in Atom text editor.
Please, always post full traceback, in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Hi buran
This is the code i have been using:

#!/usr/bin/env python3.6 

# import module
import calendar

yy = 2018
mm = 11

# To ask month and year from the user
# yy = int(input("Enter year: "))
# mm = int(input("Enter month: "))

# display the calendar
print(calendar.month(yy, mm))
And this is the output.

oldD@my-desktop-ubuntu-mate:~$ python3 ~/my_python3/calendar.py
Traceback (most recent call last):
  File "/home/oldDog/my_python3/calendar.py", line 6, in <module>
    import calendar
  File "/home/oldDog/my_python3/calendar.py", line 15, in <module>
    print(calendar.month(yy, mm))
AttributeError: 'function' object has no attribute 'month'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
    from urllib.request import urlopen
  File "/usr/lib/python3.6/urllib/request.py", line 88, in <module>
    import http.client
  File "/usr/lib/python3.6/http/client.py", line 71, in <module>
    import email.parser
  File "/usr/lib/python3.6/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/usr/lib/python3.6/email/feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "/usr/lib/python3.6/email/_policybase.py", line 9, in <module>
    from email.utils import _has_surrogates
  File "/usr/lib/python3.6/email/utils.py", line 33, in <module>
    from email._parseaddr import quote
  File "/usr/lib/python3.6/email/_parseaddr.py", line 16, in <module>
    import time, calendar
  File "/home/oldDog/my_python3/calendar.py", line 15, in <module>
    print(calendar.month(yy, mm))
AttributeError: 'function' object has no attribute 'month'

Original exception was:
Traceback (most recent call last):
  File "/home/oldDog/my_python3/calendar.py", line 6, in <module>
    import calendar
  File "/home/oldDog/my_python3/calendar.py", line 15, in <module>
    print(calendar.month(yy, mm))
AttributeError: 'function' object has no attribute 'month'
oldDog@my-desktop-ubuntu-mate:~$
Big thanks for any and all help
Reply
#4
Rename calendar.py(what calendar use) to eg my_calender.py.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Run School Bell by Google Calendar darkmx6 1 2,001 Oct-29-2019, 02:12 AM
Last Post: Larz60+
  How to generate calendar with 2 formats in python luizcrf 1 2,655 Nov-01-2018, 06:46 AM
Last Post: Larz60+
  How to read calendar appointments in outlook TilakGopi 2 11,661 Apr-05-2018, 02:58 PM
Last Post: TilakGopi
  Google Calendar & Python MeeranRizvi 2 8,478 May-29-2017, 12:55 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020