Loading a model by creating a seperate py file

The problem is that the use of the loader from ShowBase itself is fundamentally wrong. Also note that the logic that can be executed many times in the __init __ area is also fundamentally wrong.

Your new bootloader might look like this.

file: ModelLoader.py

from panda3d.core import Loader, NodePath

class loadMyModel():
    def __init__(self):
        self.loader = Loader.get_global_ptr()

    def load(self, model):
        ob = self.loader.load_sync(model)

        return NodePath(ob)

file: main.py

from direct.showbase.ShowBase import ShowBase
from ModelLoader import loadMyModel

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        load_my_model = loadMyModel()

        self.panda = load_my_model.load("panda")
        self.panda.setPos(0, 5, 0)
        self.panda.reparentTo(render)

        self.box = load_my_model.load("box")
        self.box.setPos(0, -5, 0)
        self.box.reparentTo(render)

app = MyApp()
app.run()