UnicodeDecodeError when loading DNA in MetaHuman for Maya Expression Editor on non-English Windows

Summary

UnicodeDecodeError when loading DNA in MetaHuman for Maya Expression Editor on non-English Windows

Please select what you are reporting on:

Creative

What Type of Bug are you experiencing?

Other

Steps to Reproduce

Use a non-English Windows system (e.g., Windows 10/11 Traditional Chinese).

Open Maya and load MetaHuman for Maya (tested with Expression Editor 1.9.7).

In the Expression Editor, try to load a DNA file.

Expected Result

The DNA file should load successfully in the Expression Editor. The rig definition should be imported without errors, and all Expression Editor features should work as intended.

Observed Result

Maya immediately throws the following error:

Traceback (most recent call last):

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\mh_expression_editor\1.9.7\mh_expression_editor\window.py”, line 1411, in on_load_btn_clicked

**self.config[“pruning_threshold”],

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\frt_api\2.1.0\frt_api\publisher.py”, line 62, in wrapper

raise e

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\frt_api\2.1.0\frt_api\publisher.py”, line 57, in wrapper

result = func(*args, **kwargs)

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\frt_api\2.1.0\frt_api\core.py”, line 18, in inner_wrapper

res = func(*args, **kwargs)

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\frt_api\2.1.0\frt_api\rig\rig.py”, line 204, in init

self.rig_definition, self.rdf_reader = get_rig_definition(binary_rig_definition_file_path)

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\frt_api\2.1.0\frt_api\model\rdf\mapper.py”, line 19, in get_rig_definition

reader.read()

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\rdf_model\0.20.0\rdf_model\file\reader.py”, line 155, in read

self._open_reader()

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\rdf_model\0.20.0\rdf_model\file\reader.py”, line 137, in _open_reader

ver = read_fileformat_version(self._rdf_path)

File “C:\Program Files\Epic Games\MetaHumanForMaya\lib\rdf_model\0.20.0\rdf_model\file\reader.py”, line 752, in read_fileformat_version

header = f.read(7)

UnicodeDecodeError: ‘cp950’ codec can’t decode byte 0xae in position 34: illegal multibyte sequence

Platform(s)

Windows 11 64-bit (Traditional Chinese locale)
Maya 2024.5
Python 3.9.7
MetaHuman for Maya 1.9.7

Upload an image

Additional Notes

I investigated the issue and identified the cause:
The function read_fileformat_version in rdf_model/file/reader.py opens the rig/DNA file using text mode (i.e., open(filepath)), which causes Python to decode binary data using the system codepage (such as cp950 on Traditional Chinese Windows). This leads to UnicodeDecodeError when loading files on non-English systems.

Temporary Solution (Manual Patch):
Navigate to the file:

C:\Program Files\Epic Games\MetaHumanForMaya\lib\rdf_model\0.20.0\rdf_model\file\reader.py

Locate the function read_fileformat_version (around line 752):

Modify the function called [def read_fileformat_version(filepath) → str …] to below version

def read_fileformat_version(filepath) → str:
with open(filepath, ‘rb’) as f: # Open in binary mode
header = f.read(7)
if len(header) < 7:
raise ValueError(“Header too short”)
if header[0:3] != b"RDF": # Compare using bytes
raise ValueError(“Not a valid RDF file”)

    # Unpack directly from bytes, no need for ord()
    generation, = struct.unpack("!h", header[3:5])
    version, = struct.unpack("!h", header[5:7])

    return f"{generation}.{version}"

Hey Everyone,

Just to let you know that we have deployed a fix for this issue. There will be an updated MetaHuman for Maya version available for you in the Epic Game Launcher.

Cheers
James

1 Like