0

I'm only a few hours new to python language. I've downloaded Pycharm and the current update is 3.7. I'm suppose to write a calendar program that reads from the command line. This program I was testing came off the internet somewhere, but it gives me an error after I input the year and date. Could someone more knowledgeable about pycharm help me out?

import calendar

# Enter in format - 2018, 1997, 2003 etc.
year = int(input("Enter Year: "))

# Enter in format - 01, 06, 12 etc.
month = int(input("Enter Month: "))

# printing Calendar
print(calendar.month(year, month))

OUTPUT

Enter Month: 01
Traceback (most recent call last):
  File "C:/Users/Owner/PycharmProjects/frequency_counter/calendar.py", line 5, in <module>
    import calendar
  File "C:\Users\Owner\PycharmProjects\frequency_counter\calendar.py", line 14, in <module>
    print(calendar.month(year, month))
TypeError: 'int' object is not callable

Process finished with exit code 1
sushanth
  • 8,275
  • 3
  • 17
  • 28
  • `3.7` may be Python version, not Pycharm one ;) – azro Jul 18 '20 at 17:28
  • Is that all the code in the file ? Because that code is OK and runs well – azro Jul 18 '20 at 17:29
  • 1
    Did you name your file `calendar.py` or another file like that ? If yes, don't – azro Jul 18 '20 at 17:30
  • 1
    Does this answer your question? [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Tadhg McDonald-Jensen Jul 18 '20 at 17:30
  • 1
    @azro look at traceback: `...ncy_counter/calendar.py", line 5` that is absolutely the issue here. – Tadhg McDonald-Jensen Jul 18 '20 at 17:31
  • **Don't call a python file the same as an existing module name** – azro Jul 18 '20 at 17:32
  • "I'm only a few hours new to python language" how could you possibly expect them to know that? asking the question and closed as duplicate that explains the issue seems perfectly reasonable to me. I have bookmarked that thread because I can never get it to show up in a search and the more links to it the better. – Tadhg McDonald-Jensen Jul 18 '20 at 17:35
  • Thank you all. I wasn't aware having the same name for my file would interfere with the output itself. Very appreciative of your quick replies. – WhiteWaterRafting Jul 18 '20 at 17:40

0 Answers0