TypeError: the 'module' object is not callable in pygmy

advertisements

I'm new in pygame and I have that error please help me.

    backgrounf_image_filename = 'ubisoft.jpg'
    mouse_image_filename = 'cursor.png'

    import pygame
    from pygame.locals import *
    from sys import exit

    pygame.init()

    screen = pygame.display.set_mode((640, 480), 0, 32)
    pygame.display.set_caption("Hello World!")
    background = pygame.image.load(backgrounf_image_filename).convert()
    mouse_cursor = pygame.image(mouse_image_filename).convert_alpha()

and I have that error:

    Traceback (most recent call last):
      File "C:/Users/ziyaa/PycharmProjects/pygame/helloworld.py", line 13, in <module>
        mouse_cursor = pygame.image(mouse_image_filename).convert_alpha()
    TypeError: 'module' object is not callable

    Process finished with exit code 1


You're doing:

background = pygame.image.load(backgrounf_image_filename).convert()
mouse_cursor = pygame.image(mouse_image_filename).convert_alpha()

In the second instruction, you forgot to load your image, resulting in calling the module instead of the function.

Just do:

mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()