I’m having trouble getting a Python plugin to load so I can call custom modules within the editor. It appears Unreal Engine isn’t running my `init_unreal.py` file. I can confirm that when running it via Python remote execution, the `init_unreal` code correctly adds the path to `sys.path`, allowing module imports. Additionally, editing `init_unreal.py` to point to the plugin directory and moving it to the `[Project]/Content/Python/` folder also enables automatic execution and module imports.
I would prefer to have Unreal automatically run the init_unreal.py inside the `[Plug-in]/Content/Python/` folder for cleanliness. Any suggestions on what I might be doing wrong?
I haven’t been able to reproduce this with the given steps, though I’m not sure what you’re doing with sys.path in step 3. Any Content/Python folders are automatically added to sys.path, so you shouldn’t need to do anything there to be able to import a module from the Content/Python folder of a plugin.
My test layout looks like this:
[Plug-in]/Content/Python/init_unreal.py
[Plug-in]/Content/Python/my_module/__init__.py
I’m able to run “import my_module” from either init_unreal.py or via the output log without any errors.
In the given zip, CyclopsUE.uplugin is in FWProduction/Plugins/CyclopsUE/Content. CyclopsUE.uplugin needs to be at FWProduction/Plugins/CyclopsUE for UE to recognize that as a plugin.
With that fixed, ‘import cyclops’ works fine. ‘from cyclops.hello_world_tool import hello’ still doesn’t, as it needs to be ‘from cyclops.tools.hello_world_tool import hello’ to match the folder layout.