Browser build in any plans?

Same result, still ‘not module named panda3d.core’

For checking, here is my routine:

PyObject *panda3d_module = PyImport_AddModule("panda3d");
PyModule_AddStringConstant(panda3d_module, "__package__", "panda3d");
PyModule_AddObject(panda3d_module, "__path__", PyList_New(0));

PyObject *panda3d_dict = PyModule_GetDict(panda3d_module);

PyObject *core_module = PyInit_core();
PyDict_SetItemString(panda3d_dict, "core", core_module);

PyObject *direct_module = PyInit_direct();
PyDict_SetItemString(panda3d_dict, "direct", direct_module);

PyObject *physics_module = PyInit_physics();
PyDict_SetItemString(panda3d_dict, "physics", physics_module);


    Module.setStatus('Done loading Museum.');

if (PyImport_ImportFrozenModule("__main__") < 0) {


I also put the current on my server if you want to look at it further. I have to go out for a bit.

Hmm. Not getting any errors now except “TypeError: PyType_Ready(ParticleSystemManager)”. But nothing else either. Have to check my code more carefully.

That’s part of panda3d.physics; I am not sure what that could signify, but I suggest commenting out the part where you load that module for now to see if you can get a simpler Panda program working.


But to be certain on something earlier:


goes in loadPanda not in Py_FrozenMain, right?

Yes, it needs to be put after the Panda modules are loaded.

That is where it is, and I am back to “No module named ‘panda3d.core’” with loadPanda as above but with physics lines commented out.

I’m going to see if I can copy the steps you’ve taken and make my own build of Panda and Python.

Building a Panda3d Application

  1. Get needed tools

  2. Emscripten compile python

    • terminal window
    • cd to <py source path>
    • ./<emsdk path>/
    • enter this on the console (disable-toolbox-glue is OSX only):
      BASECFLAGS=-m32 LDFLAGS=-m32 emconfigure ./configure --without-threads --without-pymalloc --disable-shared --without-signal-module --disable-toolbox-glue --disable-ipv6
    • make
      NOTE: might be some errors, but look for libpython3.8.a; if it got that far, probably ok.
    • copy libpython3.8.a to <panda3d-webgl-port path>/thirdparty/emscripten-libs/python/lib and delete any other files there
    • copy all files in the python source Include directory to <panda3d-webgl-port path>/thirdparty/emscripten-libs/python/include/python3.8/
  3. Emscripten compile panda3d

    • cd to <panda3d-webgl-port path>
    • ./<emsdk path>/
    • python makepanda/ --use-png --use-jpeg --use-egg --use-zlib --no-freetype --use-bullet --no-openssl --use-direct --use-pview --use-gles2 --use-openal --use-python --use-vorbis --no-egl --use-freetype --optimize 4 --outputdir embuilt --target emscripten --no-egl --use-freetype
      NOTE: might error out, but if you get to 92%, probably ok. Make sure there are and in the embuilt/panda3d directory.
  4. Emscripten compile and link your app

    • edit these lines in
      THIRDPARTY_DIR = “/<path to>/panda3d-webgl-port/thirdparty/emscripten-libs”
      PY_MODULE_DIR = “/<path to>/Python-3.8.6/Modules”
      PY_STDLIB_DIR = “/<path to>/Python-3.8.6/lib”
      PANDA_BUILT_DIR = “/<path to>/panda3d-webgl-port/embuilt”
      PRELOAD_FILES = [<quoted comma-separated list of EVERY asset in your application with directories such as “models/wall.bam”>]

    • either rename your app starting file to or edit the freezer.addModule line to be your file

    • cd to your application directory

    • python3.8 -OO freezify,py [double cap-O]

NOTE: I also changed all the library references in to be .o or .so as appropriate. And, I took a list of the .o files in the Modules directory and put it into PY_MODULES. Then I got lists of .a and .bc files in embuilt/lib and put them into PANDA_LIBS and PANDA_MODS. Lots of other little edits to freezify, but I assume they will be in the new source that you provide.

1 Like

Thanks, that saves me a lot of time. I’ll get it to build and see if I can get something working tomorrow.

Sorry for the update, I was still capturing.

I managed to compile everything but I’m also getting the “no module found” error. In fact, I’m getting it importing pretty much anything, not just panda3d.core. I’m going to continue investigating tomorrow.

1 Like

I did actually get further just yet, by additionally adding the loaded panda3d.core/direct modules to sys.modules programmatically, using this code:

    PyObject *sys_modules = PySys_GetObject("modules");
    PyDict_SetItemString(sys_modules, "panda3d.core", core_module);
    PyDict_SetItemString(sys_modules, "", direct_module);

This gets it through importing many of the Panda3D modules, but there are more steps needed for me. More tomorrow.

I never answered about enabling applications/wasm as a MIME type for Apache. I know about MIME types and how to set them for Apache and other servers, but if my program idea ever gets far enough, some very future version of this would be deployed at schools or other education organizations (hence the dynamic content), and I don’t want to require anything more than “unzip in a server directory”. This sounds naive, but intentionally so. That is the goal for now, no server customization.

All right, I got it working.

I struggled to get the linked-in Python modules to be recognised properly, then I realised it would be easier to just modify the Python build scripts to link all modules into libpython3.8.a, so I did that. To save you some time, I updated this archive with the new Python build, which also includes the patch I made to the Python source and the command I used to build it:

It includes my updated editor, which can be visited online here:
I also included a simpler Roaming Ralph sample, with more direct initialisation code without all the setTimeout nonsense, that is probably easier to play with:

Some notes:

  • I also committed a bunch of things to add WebGL 2 support, and change the build system to use .o files instead of .bc, so I recommend grabbing the latest source from the webgl-port branch on Git.
  • I built Panda with the --static flag, but I don’t think that doing so has any advantage (emscripten effectively forces everything to be static linking one way or the other). You may however need to adjust to use the .o files instead of .a though, unless you also build with --static.
  • I needed to force an explicit call to init_libpnmimagetypes to allow loading jpg/png files, and init_libwebgldisplay to force the display module to load, but maybe this is just because of the use of --static. This required a change to the Panda source (which I also committed).
  • I recommend running python3.8 -OO to optimise the Python modules for a slimmer build.
1 Like

Thank you very much. I especially like putting all modules in to libpython. Going forward, is there a script/kit developers can use to build their own libpython with everything in it to use a different version of python (step 2 in my script), or better to just make available the different versions of the library?

Building now. Have a lot of edits for

Success! Sort of.

gobj(error): Texture::read() - couldn’t read: floors/PavingStones060_2K_Color.jpg

I did add these per your instructions:


and defined them as extern void. They are NOT in the PRELOAD (I removed them for testing), I will try to add them to PRELOAD. But it can’t be that every image has to be preloaded, I thought that was just for efficiency. So, something else I need to change to get images loaded?

My dmm_freezify is on my server.

All the asset directories such as floors are also on my server, of course.

You forgot to build a Panda with support for jpeg.

python makepanda/ --use-jpeg

Do I need that for ogg also? And maybe not for egg as all I have is bam files.

You must specify everything that you will use. The format of the images and the models are not related in any way.

–use-ogg and --use-bam are not accepted.