question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

struct.error: unpack requires a buffer of 4 bytes

See original GitHub issue

Blender 2.80 Beta [ Date: 2019-03-03 Hash: ae977d13f8e9 ] SourceIO v3.3.6 https://github.com/REDxEYE/SourceIO/releases/download/3.3.6/SourceIO.zip 4c2752f

Attempting to import a MDL v48: https://sta.sh/09oqflbli8o Please let me know if you’re unable to download the model.

MDL file type ID: IDST
MDL file version: 48
MDL stored file name: "characters/postal_babe/postal_babe.mdl"
MDL stored file size: 250,960 bytes
MDL actual file size: 250,960 bytes
MDL checksum: 9925ED6E

When the model failed to import, the following error message appeared:

 Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\__init__.py", line 58, in execute
    importer.load()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\mdl2model.py", line 70, in load
    self.model.read()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\source_model.py", line 46, in read
    self.mdl.read()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\mdl_readers\mdl_v48.py", line 22, in read
    self.read_bone_flex_drivers()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\mdl_readers\mdl_v48.py", line 180, in read_bone_flex_drivers
    mouth.read(self.reader)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\data_structures\mdl_data.py", line 1458, in read
    self.bone = reader.read_int32()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\byte_io_mdl.py", line 175, in read_int32
    return self.read('i')
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\SourceIO\byte_io_mdl.py", line 159, in read
    return struct.unpack(t, self._read(size))[0]
struct.error: unpack requires a buffer of 4 bytes

location: <unknown location>:-1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
REDxEYEcommented, Mar 8, 2019

This is the problem i know about, LODs my addon does not resolve them correctly

0reactions
0Curtain0commented, Jan 17, 2020

This is the problem i know about, LODs my addon does not resolve them correctly

@REDxEYE I forgot to ask, do you want to open a separate issue for the LOD problem? This way it would be easier to track LOD and struct.error problem separately.

I did a new test with a different SFM model: https://sfmlab.com/item/3709/ Operating System: Pop!_OS 64bit (Based on Ubuntu) Blender 2.81a (non-Steam version / tar.bz2) SourceIO: 3.5.8

On fresh Blender startup (Blender wasn’t running before), I tried to import mechari_female_beta_bigger4_edit.mdl, and it imports successfully.

I CTRL+Z to undo the import, and then import the postal_babe.mdl (from before). The postal_babe.mdl imports into Blender but has the LOD problem, as mentioned before, ok.

I CTRL+Z again to undo the postal_babe.mdl import, and then import mechari_female_beta_bigger4_edit.mdl again, but this time I get the following error:

Traceback (most recent call last):
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 55, in read
    SourceVtxBodyPart().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 135, in read
    self.vtx_models.append(SourceVtxModel().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 156, in read
    SourceVtxModelLod().read(reader, self))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 181, in read
    self.vtx_meshes.append(SourceVtxMesh().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 207, in read
    SourceVtxStripGroup().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 266, in read
    SourceVtxStrip().read(reader, self)
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 330, in read
    self.bone_count = reader.read_uint16()
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/byte_io_mdl.py", line 177, in read_uint16
    return self.read('H')
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/byte_io_mdl.py", line 158, in read
    return struct.unpack(t, self._read(size))[0]
struct.error: unpack requires a buffer of 2 bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/__init__.py", line 86, in execute
    importer.load(dont_build_mesh=False)
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/mdl/mdl2model.py", line 80, in load
    self.model.read()
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/mdl/source_model.py", line 63, in read
    self.vtx.read()
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/mdl/vtx_readers/vtx_v7.py", line 17, in read
    self.vtx.read(self.reader)
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 63, in read
    SourceVtxBodyPart().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 135, in read
    self.vtx_models.append(SourceVtxModel().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 156, in read
    SourceVtxModelLod().read(reader, self))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 181, in read
    self.vtx_meshes.append(SourceVtxMesh().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 207, in read
    SourceVtxStripGroup().read(reader))
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 266, in read
    SourceVtxStrip().read(reader, self)
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/data_structures/vtx_data.py", line 330, in read
    self.bone_count = reader.read_uint16()
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/byte_io_mdl.py", line 177, in read_uint16
    return self.read('H')
  File "/home/user/.config/blender/2.81/scripts/addons/SourceIO/byte_io_mdl.py", line 158, in read
    return struct.unpack(t, self._read(size))[0]
struct.error: unpack requires a buffer of 2 bytes

location: <unknown location>:-1

Importing the mechari_butt.mdl appears to have no issues.

I tried File - New - General, then tried to import the mechari_female_beta_bigger4_edit.mdl again, but similar error.

It appears that the mechari_female_beta_bigger4_edit.mdl will import correctly again if I exit Blender and start it up again. However, if I import that postal_babe.mdl into Blender first, and then try to import the mechari_female_beta_bigger4_edit.mdl, the import will produce the error.

I’m on 64bit Linux, so I have no idea if this can be understood by someone who doesn’t use Linux, and I’m not 100% sure if this is a Linux only problem.

Anyway, I did mention before that there was another Blender add-on (RipImport) I was using that has a similar problem with struct.error, and a user named @luchador3d is trying to help debug it:

I recently started working on a SFM to Blender guide: Blender - Play with SFM Models but because of the current bugs that I’m experiencing on Linux, I won’t be able to do some new demos for the guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

struct.error: unpack requires a buffer of 4 bytes - Stack Overflow
struct is used for binary packed data - data that is not human-readable. b'+001.80\r' is 8 bytes long: b'+', b'0', b'0', b'1', b'.',...
Read more >
struct error: unpack requires a buffer of 4 bytes #24 - GitHub
Any help would be appreciated. Currently my Jax is 0.13.4 and the Jaxlib is 0.13.4 too. Running on CUDA11.1 with python 3.9.
Read more >
Python - Struct module error | Sololearn: Learn to code for FREE!
I just tried to reproduce it and got an error saying unpack requires a buffer of 4 bytes. Here is the code, import...
Read more >
7.1. struct — Interpret bytes as packed binary data
Iteratively unpack from the buffer buffer according to the format string fmt. This function returns an iterator which will read equally-sized chunks from...
Read more >
Traceback (most recent call last): struct.error: unpack requires ...
Python: Traceback (most recent call last): struct.error: unpack requires a buffer of 12 bytes · Coding Python Support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found