Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa1 in position 87: invalid start byte #14

Open
Olafejs opened this issue Jan 23, 2025 · 4 comments
Assignees

Comments

@Olafejs
Copy link

Olafejs commented Jan 23, 2025

MacOS + Prusaslicer after generate i have this error:

Post-processing script /usr/bin/python3 “/Users/XXX/Documents/XXX/XXX/bricklayers.py” -layerHeight 0.25 -extrusionMultiplier 1.1 on file /var/folders/fn/_Oyvdbs97rg84l_y9wfh1lqc0000gn/T/.24603_0.gcode.pp failed.
Error code: 1
Output:
Traceback (most recent call last):
File “/Users/XXX/Documents/XXX/XXX/bricklayers.py”, line 139, in process_gcode
File “/Users/XXX/Documents/XXX/XXX/bricklayers.py”, line 46, in process_gcode
lines = infile.readlines()
File “/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/codecs.py”, line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa1 in position 87: invalid start byte

Any idea where find error ? :)

@Olafejs
Copy link
Author

Olafejs commented Jan 23, 2025

Ok, error is from binary gcode of MK4S :)

@iitggithub
Copy link

iitggithub commented Jan 23, 2025

I got the same error.

In Prusaslicer, I had to go to Printers > General and uncheck "Supports Binary G-code" and then save the configuration. The script isn't designed to work with binary g-code files..... yet.

@iitggithub
Copy link

Submitted a pull request to add binary g-code support. It does however require the bgcode utility to be installed in your path.

#26

@Zendemic
Copy link

Zendemic commented Feb 4, 2025

I got the same error.

In Prusaslicer, I had to go to Printers > General and uncheck "Supports Binary G-code" and then save the configuration. The script isn't designed to work with binary g-code files..... yet.

Holy cow, I think I got it working! While trouble shooting with ChatGPT (please excuse my utter lack of coding knowledge), it gave me the following response. I am not sure if it actually changes much, but the changes seem to work allright in combination with the sugested changes above:

🛠 Fix 1: Modify the Script to Handle Encoding Errors
We need to update how the script opens the file to ignore encoding errors.

Modify bricklayers.py:
Change:

python
Copy
Edit
with open(input_file, 'r') as infile:
To:

python
Copy
Edit
with open(input_file, 'r', encoding='utf-8', errors='ignore') as infile:
Similarly, change:

python
Copy
Edit
with open(input_file, 'w') as outfile:
To:

python
Copy
Edit
with open(input_file, 'w', encoding='utf-8') as outfile:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants