For tutorial, I get error that it could not load model file

I’m working on the basic Python tutorial:

I’m using Windows 10/Anaconda/Python 3.6. When I run the file I get:

File “C:\Users\neuronet\Anaconda3\envs\p3d\lib\site-packages\direct\showbase\”, line 248, in loadModel
raise IOError(message)
OSError: Could not load model file(s): [‘models/environment’]

This was previously seen by someone who misspelled their filename:

My filename is spelled correctly, so that isn’t my issue. At this point I’m sort of at a loss. :slight_smile:

Obviously you need to check whether the file is available at the specified path.

As well as the following lines in the Config.prc file:

# These specify where model files may be loaded from.  You probably
# want to set this to a sensible path for yourself.  $THIS_PRC_DIR is
# a special variable that indicates the same directory as this
# particular Config.prc file.

model-path    $MAIN_DIR
model-path    $THIS_PRC_DIR/..
model-path    $THIS_PRC_DIR/../models

@serega-kkz C:\Users\neuronet\Anaconda3\envs\p3d\Library\share\panda3d\models\environment.egg.pz exists, and those lines are in my Config.prc file.

How to run the script through the IDE? Try it straight through the command line. Or through the BAT file.

C: \ built_x64 \ python \ python.exe

replacing the python path with your own.

Let me give more specifics.

The following works, showing an empty window:

from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
    def __init__(self):
app = MyApp()

The following yields the above error:

from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
    def __init__(self):
        # Load the environment model.
        self.scene = self.loader.loadModel("models/environment")
        # Reparent the model to render.
        # Apply scale and position transforms on the model.
        self.scene.setScale(0.25, 0.25, 0.25)
        self.scene.setPos(-8, 42, 0)
app = MyApp()

The folder C:\Users\neuronet\Anaconda3\envs\p3d\Library\share\panda3d\models is in my Python path, and contains environment.egg.pz.

I tried running from my IDE, as well as the command line, and get the same error. I tried moving the script to the above folder, and get the same error.

I’m sure I’m making a basic error but I can’t get this elementary script to work. This is my third time trying I want to use this software! :sleepy:

I am in Python 3.6.8, panda3d 1.10 in Anaconda.

OK I got it working. I was using a version I had installed using the conda installer ( I uninstalled it, and just installed using pip instead (pip install panda3d). Now it just works.

I suspect that the Anaconda package was built without zlib (or whatever the dependency is for compressed EGG files). I see that this specifies --use-zlib, but then I do not see zlib listed with the other dependencies here. If you need/want to use conda over pip, you may want to poke @Yonnji about that package.

1 Like

@Moguri that would explain some things! For now pip is fine in my conda environment, but this will be useful to have here for future reference.

This conda package is unofficial one. I made it for my game. That’s why it have the name “panda3d-kitsunetsuki”. It’s difficult to build Panda3D with everything on, so I disabled some options. It would be great to have an official conda packages because they have an include files which could be useful in some cases.

1 Like

@Yonnji I agree it would be nice to have an official conda install, as it is a lot of work to maintain things witih conda-forge etc… At any rate, things are working well for me now in Conda just using pip, so no worries. Just happy to be coding and having it all work. :slight_smile: