0

I'm just beggining panda3d on python until a came across a problem with the showbase.py module in the panda3d folder( Which is in site-packages. /home/pi/.local/lib/python3.5/site-packages) I'm running on a raspberry pi 3B. The location of Showbase.py is /home/pi/.local/lib/python3.5/site-packages/panda3d/direct/src/showbase)

Code :

from panda3d.direct.src.showbase import *

class Window(ShowBase):

    def __init__(self):

        Showbase.__init__(self)

game = Window()
game.run()

I'm not going to show Showbase.py because it's 3025 lines long :|

Error :

Traceback (most recent call last):
  File "/home/pi/Desktop/Pandas3D/window.py", line 3, in <module>
    class Window(ShowBase):
NameError: name 'ShowBase' is not defined

Thanks for any help!

Guydangerous99
  • 147
  • 1
  • 12

2 Answers2

1

The correct way to import the ShowBase class is to import it from the ShowBase module inside the direct.showbase package:

from direct.showbase.ShowBase import ShowBase

Note that the module is named ShowBase and the class inside it is also named ShowBase, hence the duplication. A common error is to try to import the module instead of the class.

It seems from your code that you have copied the direct source tree into the panda3d package inside site-packages. This is not how Panda is meant to be used. The direct tree should be a separate package, and should not have an intervening src directory.

Also, you have a capitalisation error in Showbase.__init__ which should be ShowBase.__init__.

rdb
  • 1,488
  • 1
  • 14
  • 24
  • I still get an error: Traceback (most recent call last): File "/home/pi/Desktop/Pandas3D/ShowbaseTest.py", line 1, in from direct.showbase.Showbase import ShowBase ImportError: No module named 'direct – Guydangerous99 Dec 27 '17 at 09:05
  • Could you elaborate how you installed Panda3D onto your machine, step by step? – rdb Dec 27 '17 at 23:23
  • I am on raspberry pi and I installed it using pip3 install panda3d. But when I try it again it gives me an error: Could not find a version that satisfies the requirement panda3d (from versions: ) No matching distribution found for panda3d – Guydangerous99 Jan 09 '18 at 19:33
  • It's not possible to install Panda3D via `pip` on the raspberry pi. – rdb Jan 10 '18 at 09:13
  • Kk, how do I do it then? – Guydangerous99 Jan 29 '18 at 19:57
  • You'll need to compile it from source. We don't provide binary builds for the raspberry pi at this moment. – rdb Jan 29 '18 at 21:01
0

so you need to use a super function and inherit from the showBase class

from direct.showbase.ShowBase import ShowBase

class Window(ShowBase):
    def __init__(self):
        super().__init__()

app = Window()
app.run()

try that

error 1044
  • 111
  • 1
  • 6