touilleMan / godot-python

Python support for Godot 🐍🐍🐍
Other
1.83k stars 136 forks source link

godot3 export python problem #393

Closed gnuchanos closed 5 months ago

gnuchanos commented 9 months ago
ERROR: Can't open dynamic library: addons/pythonscript/x11-64/libpythonscript.so. Error: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
   at: open_dynamic_library (drivers/unix/os_unix.cpp:418)
ERROR: No loader found for resource: res://testScene.py.
   at: _load (core/io/resource_loader.cpp:278)
ERROR: res://testScene.tscn:3 - Parse Error: [ext_resource] referenced nonexistent resource at: res://testScene.py
   at: poll (scene/resources/resource_format_text.cpp:412)
ERROR: Failed to load resource 'res://testScene.tscn'.
   at: load (core/io/resource_loader.cpp:206)
ERROR: Failed loading resource: res://testScene.tscn. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:270)
ERROR: Failed loading scene: res://testScene.tscn
   at: start (main/main.cpp:2107)                                                                                       
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object.cpp:2070)                                                                                 
ERROR: Resources still in use at exit (run with --verbose for details).
   at: clear (core/resource.cpp:417)                                                                                    
ERROR: There are still MemoryPool allocs in use at exit!

https://github.com/touilleMan/godot-python/assets/117280480/9c468c55-30ee-4a86-bf99-17485fa9044c

gnuchanos commented 9 months ago

2023-10-09-151527_627x200_scrot It works if the addon and .py script files are in the same place as the build export.

Pythonscript 0.50.0 (CPython 3.8.5.final.0)
ERROR: Failed to retrieve non-existent singleton 'VisualScriptEditor'.
   at: get_singleton_object (core/engine.cpp:201)
Cannot retreive singleton VisualScriptEditor
this is test script

@touilleMan hellooooo

touilleMan commented 5 months ago

Hi @gnuchanos

Godot's export system takes all resources and bundle them together in a single file.

However this is not compatible with how Python works (when doing import foo Python will try to load foo.py or foo/__init__.py [^1]), nor how shared library like libpython.so (on which libpythonscript.so depends) are loaded by the OS (here again, the OS need to load the library from the filesystem)

For those reasons, it's tricky to implement Python integration into the Godot export (not impossible though, but so far no work has been done on it).

So in the end the Godot export totally ignore the Python stuff, hence your error :'( But as you saw, you can fix it by manually adding the Python stuff back into the export folder :smiley:

[^1]: Python is more complicated than that and it's possible to tweak it to load modules from basically anywhere, but it's a rabbit hole not really relevant to the current issue, so I cut it simple here ^^