Hi i am new and i am currently facing a problem and i need a solution ASAP. Because i am rushing a project tomorrow. the problem is this. whenever i run panda, this error will occur and i tried to create a new file with only import directstart and the error will be something like it cannot find showbase.
Anyways here is my codes. feel free to take a look. I am a student using panda for school projects so if theres anything wrong with my code, please feel free to correct me. Thanks. My workstation is on windows 7 x64.
I have checked with people on the irc, they told me to check my sys path in system variable and i have checked. i have even uninstalled 5 times and reinstalled. I am now installed with panda nightly. i have tried using 1.7.0, 1.6.2. and 1.7.1 nightly today’s build. Thanks people if anybody can help me. Pardon me for the messy post because i am currently in a rush to fix the panda problem.
MY CODE:
###--------------------------------
### Game prototype
###--------------------------------
import direct.directbase.DirectStart
from pandac.PandaModules import *
### from direct.task import Task
import sys
class game(object):
speed = 120
stop = Vec3(0)
rotateUp = Vec3(0,0,1)
rotateDown = Vec3(0,0,-1)
rotateLeft = Vec3(-0.5,0,0)
rotateRight = Vec3(0.5,0,0)
rotateP = stop
rotateH = stop
### rotateP = Vec3(0,1,0)
### rotateH = Vec3(0,0,0)
moveX = stop
moveZ = stop
moveUp = Vec3(0,1,0)
moveDown = Vec3(0,-1,0)
moveLeft = Vec3(-1,0,0)
moveRight = Vec3(1,0,0)
moveUD = stop ### Up/Down
moveLR = stop ### Left/Right
###-------------------------------------------------
### Initialization codes here
###-------------------------------------------------
def __init__(self):
self.loadKeyboard()
self.loadFloor()
self.loadNPC()
self.loadGui()
self.loadCamera()
self.runGameLoop()
self.showLinePosition()
return
def loadKeyboard(self):
### This is to exit with the escape key
base.accept("escape", sys.exit)
### Class must include object if not self.__setattr__ fails
base.accept("w", self.__setattr__,["rotateP", self.rotateUp])
base.accept("a", self.__setattr__,["rotateH", self.rotateLeft])
base.accept("s", self.__setattr__,["rotateP", self.rotateDown])
base.accept("d", self.__setattr__,["rotateH", self.rotateRight])
base.accept("w-up", self.__setattr__,["rotateP", self.stop])
base.accept("a-up", self.__setattr__,["rotateH", self.stop])
base.accept("s-up", self.__setattr__,["rotateP", self.stop])
base.accept("d-up", self.__setattr__,["rotateH", self.stop])
base.accept("arrow_up", self.__setattr__,["moveZ", self.moveUp])
base.accept("arrow_down", self.__setattr__,["moveX", self.moveDown])
base.accept("arrow_left", self.__setattr__,["moveZ", self.moveLeft])
base.accept("arrow_right", self.__setattr__,["moveX", self.moveRight])
base.accept("arrow_up-up", self.__setattr__,["moveZ", self.stop])
base.accept("arrow_down-up", self.__setattr__,["moveX", self.stop])
base.accept("arrow_left-up", self.__setattr__,["moveZ", self.stop])
base.accept("arrow_right-up", self.__setattr__,["moveX", self.stop])
return
def loadFloor(self):
### Load the floor model
### Note: here i use a .bam model because bam load faster
floor = loader.loadModel('3D Level Design.bam')
floor.setPos(0,50,10)
floor.setHpr(0,0,0)
floor.setScale(1.1,1.1,1.1)
floor.reparentTo(render)
floorTile = [None for i in range(25)]
### Make the floor tile like a checkerboard
### But first set some variables first
startX = -10
startY = 35
startZ = 11
for i in range(25): ### here the model i scale it to 25
if i % 5 == 0:
### 5 per row according to model's scale which is 25
startX = -10
startY += 5
if i % 2 == 1:
### Tile i is white(Whatever color you want)
floorTile[i] = loader.loadModel("floortile.bam")
floorTile[i].setPos(startX,startY,startZ)
floorTile[i].reparentTo(render)
startX += 5
elif i % 2 == 0:
floorTile[i] = loader.loadModel("floortile 2.bam")
floorTile[i].setPos(startX,startY,startZ)
floorTile[i].reparentTo(render)
startX += 5
return
def loadNPC(self):
npc = loader.loadModel('npc.bam')
npc.setPos(0,0,0)
npc.reparentTo(render)
return
def loadGui(self):
pass
def loadCamera(self):
### Set camera lens and the field of view
### Set up the camera
lens = base.cam.node().getLens()
lens.setFov(60)### 70
base.cam.node().setLens(lens)
self.cam = NodePath("camera")
self.cam.setPos(0,-1,20)
###self.cam.setP(-30)
self.cam.reparentTo(render)
base.camera.reparentTo(self.cam)
### base.disableMouse()
def loadCollision(self):
pass
def showLinePosition(self):
### Not needed in game but print blocks of models for visual representation
lineX = [None for i in range(30)]
lineY = [None for i in range(30)]
lineZ = [None for i in range(30)]
startX = 0
startY = 0
startZ = 0
distance = 30
for i in range(30):
if i % 2 == 1:
startX = startX + distance
startY = startY + distance
startZ = startZ + distance
lineX[i] = loader.loadModel("floortile.bam")
lineX[i].setPos(startX,0,0)
lineX[i].reparentTo(render)
lineY[i] = loader.loadModel("floortile.bam")
lineY[i].setPos(0,startY,0)
lineY[i].reparentTo(render)
lineZ[i] = loader.loadModel("floortile.bam")
lineZ[i].setPos(0,0,startZ)
lineZ[i].reparentTo(render)
return
###--------------------------------------------
### Realtime Codes here
###--------------------------------------------
def runGameLoop(self):
### When DirectStart is called, i found out that
### task is being called therefore run() can be called
### run() is a task run by the global task manager
### So taskMgr can be called with the base command
base.taskMgr.add(self.runNPCMovement, "runNPCMovement")
base.taskMgr.add(self.runTimer, "runTimer")
base.taskMgr.add(self.runPickupItems, "runPickupItems")
base.taskMgr.add(self.runChecks, "runChecks")
base.taskMgr.add(self.runCamera, "runCamera")
return
def runNPCMovement(self, task):
### Let NPC walks
return task.cont
def runTimer(self, task):
### Run in game timer because each level have its own time
return task.cont
def runPickupItems(self, task):
### Check if mouse pick up anything
return task.cont
def runChecks(self, task):
### Checks if everything is fine and if game is finish
return task.cont
def runCamera(self, task):
### In the following setHpr, we provide 2 arguments
### the first one is is to tell which item is it for
### the second one is a Vec3 threfore hold 3 values
### self.cam.setHpr(self.cam, self.rotateP * globalClock.getDt()* self.speed)
self.cam.setHpr(self.cam, self.rotateH * globalClock.getDt() * self.speed)
self.cam.setPos(self.cam, self.rotateP * globalClock.getDt()* self.speed)
self.cam.setPos(self.cam, self.rotateH * globalClock.getDt() * self.speed)
self.cam.setPos(self.cam, self.moveX * globalClock.getDt() * self.speed)
self.cam.setPos(self.cam, self.moveZ * globalClock.getDt() * self.speed)
return task.cont
game()
run()
ERROR:
C:\Users\Pigs Can Fly\Desktop\EYE\Game>run
C:\Users\Pigs Can Fly\Desktop\EYE\Game>python main.py
DirectStart: Starting the game.
Traceback (most recent call last):
File "main.py", line 5, in <module>
import direct.directbase.DirectStart
File "C:\Panda3D-1.7.1\direct\directbase\DirectStart.py", line 3, in <module>
from direct.showbase import ShowBase
File "C:\Panda3D-1.7.1\direct\showbase\ShowBase.py", line 10, in <module>
from pandac.PandaModules import *
File "C:\Panda3D-1.7.1\pandac\PandaModules.py", line 26, in <module>
from libp3directModules import *
File "C:\Panda3D-1.7.1\pandac\libp3directModules.py", line 15, in <module>
from direct.directnotify.DirectNotifyGlobal import directNotify
File "C:\Panda3D-1.7.1\direct\directnotify\DirectNotifyGlobal.py", line 3, in
<module>
import DirectNotify
File "C:\Panda3D-1.7.1\direct\directnotify\DirectNotify.py", line 5, in <modul
e>
import Notifier
File "C:\Panda3D-1.7.1\direct\directnotify\Notifier.py", line 6, in <module>
from direct.showbase import PythonUtil
File "C:\Panda3D-1.7.1\direct\showbase\PythonUtil.py", line 48, in <module>
import new
File "C:\Users\Pigs Can Fly\Desktop\EYE\Game\new.py", line 3, in <module>
from direct.task import Task
File "C:\Panda3D-1.7.1\direct\task\Task.py", line 10, in <module>
from direct.showbase import ExceptionVarDump
File "C:\Panda3D-1.7.1\direct\showbase\ExceptionVarDump.py", line 1, in <modul
e>
from pandac.PandaModules import getConfigShowbase
ImportError: cannot import name getConfigShowbase
C:\Users\Pigs Can Fly\Desktop\EYE\Game>
If Anyone have a clue as to what happen, you can feel free to email me as well @ ggneverdie@gmail.com or gimme a pm. Thanks.