TypeError: 'module' object is not callable?

Sorry to do this people, but I’ve run into another snag. You see, I decided to expand upon my keyboard camera code to include keyboard controls for an animated actor.

But I’m getting this error whenever I try to run it (I’ve made sure that all the relevant models are in the MODELS folder in the same directory that I’m running the script from):

Here is the code itself if that’s of any help (I’m using Panda3D version 1.0.5):

# KeyboardControls.py
# Controls are w - walk forward, s - walk backward,  a - turn left, 
# d - turn right. The arrows control the camera. 

import direct.directbase.DirectStart # Start Panda
from pandac.PandaModules import* # Import the Panda Modules
from direct.showbase.DirectObject import DirectObject # To listen for Events
from direct.task import Task # To use Tasks
from direct.actor import Actor # To use animated Actors 
from direct.interval.IntervalGlobal import * # To use Intervals
import math # To use math (angles, degrees..etc)
import sys 

class Controls(DirectObject):
    def __init__(self): 
       base.disableMouse() # Disable default camera.
       self.speed = .05 # Controls speed of rotation and zoom.
       # Setup key controls
       self.accept("escape", sys.exit)
       self.accept("arrow_left", self.cameraTurn,[-1])
       self.accept("arrow_right", self.cameraTurn,[1])
       self.accept("arrow_up", self.cameraZoom,[-1])
       self.accept("arrow_down", self.cameraZoom,[1])
       self.accept("w", self.walk,[-1])
       self.accept("a", self.turn,[-1])
       self.accept("d", self.turn,[1])
       # end __init__

    def loadModels(self):
        # Load the player and its animations
        self.player = Actor("MODELS/panda-model",{"walk":"MODELS/panda-walk4"})
        self.player.reparentTo(render) # Make it display/render on the screen.
        self.player.setPos(0, 0, 0) # Position it at the center of the world.
        #Create a camera dummy node
        self.camera_dummy_node = render.attachNewNode("camera_dummy_node")
        #Position the camera dummy node
        self.camera_dummy_node.setPos( 0, 0, 0)
        # Attach the camera dummy node to the player.
        # Attach the camera to the dummy node.
        # Position the camera
        camera.setPos(0, -30, 5) # X = left & right, Y = zoom, Z = Up & down.
        camera.setHpr(0, 0, 0) # Heading, pitch, roll.
        # end loadModels
    # Define the CameraTurn function.
    def cameraTurn(self,dir):
        self.camTurn = LerpHprInterval(self.camera_dummy_node, self.speed, Point3(self.camera_dummy_node.getH()-(10*dir), 0, 0))
        # end cameraTurn
    # Define the cameraZoom function.
    def cameraZoom(self,dir):
        self.camZoom = LerpPosInterval(camera, self.speed, Point3(camera.getX(), camera.getY()-(2*dir), camera.getZ()))
        # end cameraZoom
    def walk(self,dir):
        dist = 5.0
        angle = self.player.getH()*math.pi/180
        dx = dist*math.sin(angle)
        dy = dist*math.cos(angle)
        playerWalk = Parallel(
    def turn(self,dir):
        playerTurn = self.player.hprInterval(.2, Vec3(self.player.getH()-(10*dir),0,0))
# end class Controls

c = Controls()


I’ve gone over and over it, but it looks almost identical to the tutorial that I’m working from. Maybe a fresh pair of eyes can see what I’ve done wrong. Any advice is most welcome.


Hmm thats strange if you use

from direct.actor import actor

you are importing a Module named Actor
To use the actor class you have to use


self.player = Actor.Actor("MODELS/panda-model",{"walk":"MODELS/panda-walk4"})


Thankyou Martin, that fixed it. Where would I be without you :unamused:?

I’m following the BVW tutorial, and it uses:

self.panda = Actor("panda",{"walk":"panda-walk"})

I guess things have changed a little since that tutorial was written sigh life is very hard for newbies.

Thanks again.