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\Loader.py”, 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.
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
from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
app = MyApp()
app.run()
The following yields the above error:
from direct.showbase.ShowBase import ShowBase
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Load the environment model.
self.scene = self.loader.loadModel("models/environment")
# Reparent the model to render.
self.scene.reparentTo(self.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()
app.run()
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!
OK I got it working. I was using a version I had installed using the conda installer (https://anaconda.org/kitsune.one/panda3d-kitsunetsuki). 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.
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.
@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.