Ayon Unreal Plugin: Button Doesn’t Work Due to Missing ayon_core Module (PYTHONPATH Not Added to sys.path)
Environment:
- Unreal Engine 5.6
- Ayon Launcher 1.4.1
- Ayon Core 1.7.2
- Ayon Unreal 0.2.15
- Ayon Unreal Plugin: From Github (lastest Version), Automatically installed and builded by myself
- Windows
When launching Unreal Engine via the Ayon desktop launcher and clicking the Ayon button in the toolbar, I see the following log message:
LogPython: Warning: Ayon: showing tools popup
But no popup or dialog appears. Investigating further, the root cause is that the Ayon integration fails to load during startup, with this error:
LogPython: Error: Ayon: cannot load Ayon integration [ No module named 'ayon_core' ]
Investigation:
The Ayon launcher correctly sets the PYTHONPATH environment variable, which includes the necessary paths for Ayon modules. For example, when checked in Unreal’s Python console:
PYTHONPATH: C:\Program Files (x86)\Ayon\AYON 1.4.1\common;C:\Program Files (x86)\Ayon\AYON 1.4.1\dependencies;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\core_1.7.2\ayon_core\vendor\python;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\applications_1.3.1;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\ayon_third_party_1.4.0;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\blender_1.0.10-dev1;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\core_1.7.2;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\houdini_0.9.1-dev1;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\maya_0.4.18;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\nuke_0.3.13-dev1;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\photoshop_0.3.2;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\royalrender_0.3.1-dev1;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\traypublisher_0.3.8;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\unreal_0.2.15;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\usd_0.1.4;C:\Users\jbloenni\AppData\Local\Ynput\AYON\addons\version_control_0.1.0;C:\Users\jbloenni\AppData\Local\Ynput\AYON\dependency_packages\ayon_2510091624_windows.zip\dependencies
However, Unreal Engine’s embedded Python does not automatically add PYTHONPATH to sys.path (unlike a standard Python interpreter). As a result, sys.path only contains Unreal’s default paths, and the Ayon imports fail.
I fixed this by modifying the plugin’s init_unreal.py file to manually parse PYTHONPATH and add the paths to sys.path before attempting the imports. Here’s the updated code at the top of the file:
# Copyright (c) 2025 Ynput s.r.o.
import unreal
import sys
import os
# Add PYTHONPATH to sys.path since Unreal doesn't do it automatically
pythonpath = os.environ.get('PYTHONPATH', '')
if pythonpath:
for path in pythonpath.split(';'):
if path and path not in sys.path:
sys.path.insert(0, path)
ayon_detected = True
try:
from ayon_core.pipeline import install_host
from ayon_unreal.api import UnrealHost
ayon_host = UnrealHost()
# ... rest of the code
After this change, the Ayon integration loads successfully, and the button works as expected.
Question:
Is there a configuration or setting I’m missing that would make Unreal automatically include PYTHONPATH in sys.path? It seems like the plugin should handle this automatically, especially since the Ayon launcher sets PYTHONPATH correctly.