Please note: I have fixed this issue, see notes below (I asked Claude AI).
Bug: SyntaxError 'expected else after if expression' on Linux with UE5.6 / Blender 5.1
Environment:
- OS: Pop!_OS Linux
- Blender: 5.1 (Python 3.13)
- Unreal Engine: 5.6.1
- send2ue: 2.6.7
Symptoms:
After successfully connecting via remote execution, any asset send attempt fails with:
LogPython: Error: File "<string>", line 3
Checks to see if a directory exist in unreal.
^^^^^^^^
LogPython: Error: SyntaxError: expected 'else' after 'if' expression
The word if inside a docstring is being parsed as a Python keyword by UE's interpreter.
Root Cause:
In rpc/factory.py, _get_code() extracts the docstring via function.__doc__, which Python automatically strips of indentation and surrounding whitespace. When replace(doc_string, '') is called on the full indented source, it never matches, leaving the raw docstring text in the code string sent to UE for exec(). UE's Python interpreter then tries to parse the docstring content as executable code.
This is a Python 3.13 regression — __doc__ normalization behavior changed, breaking the string match against indented source.
Fix:
Replace the docstring removal block in _get_code() in rpc/factory.py:
# BEFORE
if doc_string:
code = '\n'.join(code).replace(doc_string, '')
code = [line for line in code.split('\n') if not all([char == '"' or char == "'" for char in line.strip()])]
# AFTER
# remove the doc string using regex to handle indentation mismatches
code_str = '\n'.join(code)
code_str = re.sub(r'(\s*)(\'\'\'|""")[\s\S]*?\2', '', code_str)
code = [line for line in code_str.split('\n') if line.strip() != '']
Additional Linux-specific setup notes:
- UE5.6 ini key is
RemoteExecutionMulticastGroupEndpoint (not RemoteExecutionMulticastEndpoint as in older versions)
- On Linux, multicast bind address
0.0.0.0 works for both UE and send2ue (pinning to LAN IP breaks UE's ability to receive multicast packets)
- Ensure only one UnrealEditor process is running (
ss -unlp | grep 6766) — stale background instances from previous sessions will silently swallow packets
- Interchange FBX importer must be disabled:
Interchange.FeatureFlags.Import.FBX False
Please note: I have fixed this issue, see notes below (I asked Claude AI).
Bug: SyntaxError 'expected else after if expression' on Linux with UE5.6 / Blender 5.1
Environment:
Symptoms:
After successfully connecting via remote execution, any asset send attempt fails with:
The word
ifinside a docstring is being parsed as a Python keyword by UE's interpreter.Root Cause:
In
rpc/factory.py,_get_code()extracts the docstring viafunction.__doc__, which Python automatically strips of indentation and surrounding whitespace. Whenreplace(doc_string, '')is called on the full indented source, it never matches, leaving the raw docstring text in the code string sent to UE forexec(). UE's Python interpreter then tries to parse the docstring content as executable code.This is a Python 3.13 regression —
__doc__normalization behavior changed, breaking the string match against indented source.Fix:
Replace the docstring removal block in
_get_code()inrpc/factory.py:Additional Linux-specific setup notes:
RemoteExecutionMulticastGroupEndpoint(notRemoteExecutionMulticastEndpointas in older versions)0.0.0.0works for both UE and send2ue (pinning to LAN IP breaks UE's ability to receive multicast packets)ss -unlp | grep 6766) — stale background instances from previous sessions will silently swallow packetsInterchange.FeatureFlags.Import.FBX False