.gltf not detect in .exe

When i export .py file to .exe, when program start in console i see error open model (i use .gltf) link to my code

Is your model included with your executable? That is, is the model found in the same place relative to your executable as it is in the unexported version?

Another thought: How are you exporting your program to .exe?

Finally, could you post the full error message that you’re seeing?

error:

Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
:loader(error): Extension of file models/).gltf is unrecognized; cannot load.
Currently known scene file types are:
Bam
bam
:loader(error): Couldn't load file models/) gltf: all matching files on model path invalid (the model path is currently:
"/"/c/Code Master/Panda_3d/city/build/win_amd64;/…;/…/models")
Traceback (most recent call last):
File "_main_"
line 21, in <module>
File "
main_",
, line 14, in _init_
File "direct. showbase.Loader", line 298, in loadModel
OSError: Could not load model file(5): ['models/).gltf']

Is your model included with your executable? That is, is the model found in the same place relative to your executable as it is in the unexported version?

Yes

Another thought: How are you exporting your program to .exe?

python setup.py build_apps

from setuptools import setup

setup(
    name="Game_300_IQ",
    options = {
        'build_apps': {
            'include_patterns': [
                '**/*.gltf'
            ],
            'console_apps': {
                'Game_300_IQ': 'main.py',
            },
            'log_append': False,
            'plugins': [
                'pandagl',
                'p3openal_audio',
            ],
            'platforms':['win_amd64']
        }
    }
)

Welcome to the community!

You need to put panda3d-gltf on a new line in your requirements.txt file.

1 Like

It didn’t work

requirements.txt

panda3d
panda3d-gltf
panda3d-simplepbr

setup.py

from setuptools import setup

setup(
    name="300IQ Game",
    options = {
        'build_apps': {
            'platforms':["win_amd64"],
            'include_patterns': [
                '**/*.bam',
                '**/*.gltf',
            ],
            'gui_apps': {
                '300IQ Game': 'main.py',
            },
            'log_filename': '$USER_APPDATA/Asteroids/output.log',
            'log_append': False,
            'plugins': [
                'pandagl',
                'p3openal_audio',
                'panda3d-gltf',
            ],
        }
    }
)

main.py

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self);
        self.BMP=self.loader.loadModel(r"model/f.gltf");
        self.BMP.reparentTo(self.render);
app = MyApp();
app.run();

when i build app (py to exe)
output.log

Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:loader(error): Extension of file model/f.gltf is unrecognized; cannot load.
Currently known scene file types are:
  Bam                             .bam
:loader(error): Couldn't load file model/f.gltf: all matching files on model path invalid (the model path is currently: "/c/CodeMaster/Panda_3d/city/build/win_amd64;/..;/../models")
Traceback (most recent call last):
  File "__main__", line 8, in <module>
  File "__main__", line 6, in __init__
  File "direct.showbase.Loader", line 298, in loadModel
OSError: Could not load model file(s): ['model/f.gltf']

What am I doing wrong? Python load .gltf model, .exe app not load model

You need to add panda3d-gltf to include_modules. When bundling Python code, the panda3d-gltf files are not explicitly referenced (the Python file loader uses the module dynamically), so they are not included by default.

However, even with that, I do not know if it will work since the Python file loaders rely on entry points for detection, and I doubt those are preserved through the freezing process.

I don’t recommend adding panda3d-gltf to include_modules / requirements.txt. Instead, register a handler that will convert the .gltf files to .bam at runtime:

import subprocess

def gltf2bam(_build_cmd, srcpath, dstpath):
    dstpath = dstpath + '.bam'
    subprocess.check_call(['gltf2bam', srcpath, dstpath])
    return dstpath


options = {
    'build_apps': {
        ...
        'include_patterns': [
            '**/*.gltf',
            ...
        ],
        'file_handlers': {'.gltf': gltf2bam}
        ...

Panda3D 1.10.13, which will be released very soon, will add a built-in option for converting models other than .egg to .gltf:

options = {
    'build_apps': {
        ...
        'include_patterns': [
            # Make sure the gltf/glb file is being found
            '**/*.gltf',
            '**/*.glb',
            '**/*.jpg',
            ...
        ],
        # Models with these extensions are converted to .bam automatically
        'bam_model_extensions': ['.gltf', '.glb', '.egg'],
        ...