TypeError: 'module' object is not callable: Calender module

typeerror python
typeerror: is not a function
typeerror is undefined
typeerror: is null
typeerror django
typeerror php
typeerror (ruby)
uncaught typeerror

I am using Calendar function in python for the first time this is my code:

import calendar

print ("The calender of year 2018 is : ")
print (calendar.calendar(2018,2,1,6))
print ("The starting day number in calendar is : ",end="")
print (calendar.firstweekday())

I am getting the followng output

The calender of year 2018 is : 
Traceback (most recent call last):
  File "C:/Users/AAKASH PATEL/Desktop/calendar.py", line 5, in <module>
    import calendar
  File "C:/Users/AAKASH PATEL/Desktop\calendar.py", line 10, in <module>
    print (calendar.calendar(2018,2,1,6))
TypeError: 'module' object is not callable

How can i solve this

Rename your script name from calendar.py to calendarScript.py

"C:/Users/AAKASH PATEL/Desktop/calendar.py"

to

"C:/Users/AAKASH PATEL/Desktop/calendarScript.py", 

Note: Do not name your script the same name as a module.

In Python, what's the difference between a Type Error and a Value , occurs when an operation or function is applied to an object of inappropriate type. A ValueError occurs when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError . Type I Error: A Type I error is a type of error that occurs when a null hypothesis is rejected although it is true. The error accepts the alternative hypothesis

You named your script calendar.py, so it is that file that is imported. You can see this in the traceback:

  File "C:/Users/AAKASH PATEL/Desktop/calendar.py", line 5, in <module>
    import calendar
  File "C:/Users/AAKASH PATEL/Desktop\calendar.py", line 10, in <module>
    print (calendar.calendar(2018,2,1,6))

So import calendar imported calendar.py, which now has an attribute calendar, which is your script.

Rename your script to not mask the built-in library; for example, calendar_demo.py would be fine. Once you do, it works perfectly, on my system, it outputs:

The calender of year 2018 is :
                                  2018

      January                   February                   March
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
 1  2  3  4  5  6  7                1  2  3  4                1  2  3  4
 8  9 10 11 12 13 14       5  6  7  8  9 10 11       5  6  7  8  9 10 11
15 16 17 18 19 20 21      12 13 14 15 16 17 18      12 13 14 15 16 17 18
22 23 24 25 26 27 28      19 20 21 22 23 24 25      19 20 21 22 23 24 25
29 30 31                  26 27 28                  26 27 28 29 30 31

       April                      May                       June
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                   1          1  2  3  4  5  6                   1  2  3
 2  3  4  5  6  7  8       7  8  9 10 11 12 13       4  5  6  7  8  9 10
 9 10 11 12 13 14 15      14 15 16 17 18 19 20      11 12 13 14 15 16 17
16 17 18 19 20 21 22      21 22 23 24 25 26 27      18 19 20 21 22 23 24
23 24 25 26 27 28 29      28 29 30 31               25 26 27 28 29 30
30

        July                     August                  September
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                   1             1  2  3  4  5                      1  2
 2  3  4  5  6  7  8       6  7  8  9 10 11 12       3  4  5  6  7  8  9
 9 10 11 12 13 14 15      13 14 15 16 17 18 19      10 11 12 13 14 15 16
16 17 18 19 20 21 22      20 21 22 23 24 25 26      17 18 19 20 21 22 23
23 24 25 26 27 28 29      27 28 29 30 31            24 25 26 27 28 29 30
30 31

      October                   November                  December
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
 1  2  3  4  5  6  7                1  2  3  4                      1  2
 8  9 10 11 12 13 14       5  6  7  8  9 10 11       3  4  5  6  7  8  9
15 16 17 18 19 20 21      12 13 14 15 16 17 18      10 11 12 13 14 15 16
22 23 24 25 26 27 28      19 20 21 22 23 24 25      17 18 19 20 21 22 23
29 30 31                  26 27 28 29 30            24 25 26 27 28 29 30
                                                    31

The starting day number in calendar is : 0

Note that calendar.calendar(2018) would suffice; the defaults for the next three arguments (w for the column width, l for lines per week, and c for the spacing between month columns) are 2, 1 and 6 respectively.

Proper way in Python to raise errors while setting variables, getName(), but you did a spelling mistake and try to invoke as Person. getNamme(). Introduction There are three scenarios where a TypeError may be thrown. The first is where the argument type being passed to a function does not match its corresponding declared parameter type. The second is where a value being returned from a function does not match the declared function return type.

When copying your code and executing it, it works perfectly fine! But I see that it seems your script, where you have that code is called calendar.py! Python then thinks this is what you want to import! So rename your script to something else!

JavaScript Error Handling - X Is Not a Function TypeError, The TypeError() constructor creates a new error when an operation could not be performed, typically (but not exclusively) when a value is not of  Type I errors are equivalent to false positives. Let’s go back to the example of a drug being used to treat a disease. If we reject the null hypothesis in this situation, then our claim is that the drug does, in fact, have some effect on a disease.

What does the JavaScript error 'is not a function' mean?, Error type. TypeError . What went wrong? It attempted to call a value from a function, but the value is not actually a  TypeError: bad operand type for unary ~: 'float' while groupby and apply a function. Related. 1589. How do I check if a string is a number (float)? 2210.

TypeError() constructor, (When an object does not support attribute references or attribute assignments at all, TypeError is raised.) exception EOFError ¶. Raised when the input() function  Since in a real experiment, it is impossible to avoid all the type I and type II error, it is thus important to consider the amount of risk one is willing to take to falsely reject H 0 or accept H 0. The solution to this question would be to report the p-value or significance level α of the statistic.

TypeError: "x" is not a function, A close look at the TypeError: null or undefined has no properties TypeError within JavaScript, including a quick look at null and undefined  Understanding Type I and Type II Errors Hypothesis testing is the art of testing if variation between two sample distributions can just be explained through random chance or not. If we have to conclude that two distributions vary in a meaningful way, we must take enough precaution to see that the differences are not just through random chance.

Comments
  • Look closely at your traceback. You imported your own script.
  • calendarScript: not very Pythonic (PEP8).
  • @CristiFati...its just an example :)