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

Internal error on command:"SDCARD_PRINT_FILE" #4794

Open
michi6383 opened this issue Oct 11, 2021 · 26 comments
Open

Internal error on command:"SDCARD_PRINT_FILE" #4794

michi6383 opened this issue Oct 11, 2021 · 26 comments
Labels

Comments

@michi6383
Copy link

michi6383 commented Oct 11, 2021

Internal error on command:"SDCARD_PRINT_FILE"
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/gcode.py", line 182, in _process_commands
    handler(gcmd)
  File "/home/pi/klipper/klippy/gcode.py", line 120, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 144, in cmd_SDCARD_PRINT_FILE
    self._load_file(gcmd, filename, check_subdirs=True)
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 187, in _load_file
    gcmd.respond_raw("File opened:%s Size:%d" % (filename, fsize))
  File "/home/pi/klipper/klippy/gcode.py", line 208, in respond_raw
    cb(msg)
  File "/home/pi/klipper/klippy/gcode.py", line 430, in _respond_raw
    os.write(self.fd, (msg+"\n").encode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 46: ordinal not in range(128)
Transition to shutdown state: Internal error on command:"SDCARD_PRINT_FILE"

It doesn't matter which file is selected to print. Even files that worked flawlessly before the update won't work either.

@michi6383
Copy link
Author

Ok. I found a workaround. The problem is the "µ" in the filename.
Ultiron_Fiberlogy_PETG_Ultiron_120µm_Angled_Foregrip.gcode

If you replace or remove the character it works fine.

@ontje
Copy link

ontje commented Oct 11, 2021

Happens to me as well with non ascii filenames (german "Umlaut" for example)

Körper1.gcode does not work
Korper1.gcode works (simply renamed the file, same content)

@drak42
Copy link

drak42 commented Oct 13, 2021

Glad I found this... Renaming file worked

@kolbenhans
Copy link

Jepp, same for me. Typical german Fusion 360 export of Bodies is Körper :D

wlhlm referenced this issue Oct 25, 2021
The error checking is not complete in this change - the code should
handle the case where an input string is not valid utf8.

The code will continue to run on Python2 after this change, however
the execution time on Python2 is measurably slower after making this
change.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
@github-actions
Copy link

Hello,

It looks like there hasn't been any recent updates on this
Klipper github issue. If you created this issue and no
longer consider it open, then please login to github and
close the issue. Otherwise, if there is no further activity
on this thread then it will be automatically closed in a few
days.

Best regards,

~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.

@github-actions github-actions bot added the Stale label Nov 19, 2021
@michi6383
Copy link
Author

Still existing...

@vladimir-poleh
Copy link

There are two options to work with non-ASCII characters:

  1. Use release version v0.10
  2. Switch to Python 3

@soxhi8
Copy link

soxhi8 commented Nov 25, 2021

There are two options to work with non-ASCII characters:

1. Use release version v0.10

2. Switch to Python 3

Is Klipper fully supported on Python 3 yet? According to the author of KIAUH it does not really sound like it:
dw-0/kiauh#136 (comment)

@mvoss96
Copy link

mvoss96 commented Jan 15, 2022

Can confirm this error still persists.
I wanted to print a file containing the german letter "ä" and it crashed the printer

@Sineos
Copy link
Collaborator

Sineos commented Jan 15, 2022

As long as the issue is not tagged as "resolved" it will continue to exist 😉

@CircuitGuy
Copy link

This issue got marked as a duplicate of #4959, but I think that's incorrect.

I have #4959 exactly. The same stack trace, etc. Which is not the stack trace of this issue.

Klipper seemingly won't print any files from the LCD with a space in it. For example Calibration Cube.gcode won't print, but Calibration_Cube.gcode will.

@tbb98
Copy link

tbb98 commented May 13, 2022

Strange. It has happened to me multiple times.
Spaces in folder or filenames and non-ASCII characters (íöüóőúéáű in my case) are working for weeks/months and after a while, it stops working and I have to rename them. (Moonraker + Mainsail)

kép

@RPhilbo
Copy link

RPhilbo commented Sep 14, 2022

Strange. It has happened to me multiple times. Spaces in folder or filenames and non-ASCII characters (íöüóőúéáű in my case) are working for weeks/months and after a while, it stops working and I have to rename them. (Moonraker + Mainsail)

kép

Today, for me this happend also again with an german "ü".

Everything up to date.

@webhive
Copy link

webhive commented Oct 1, 2022

Same thing. All software is up to date.

@jperrin72
Copy link

got the issue today with a French word containing accentued characters (é)

@Piezoid
Copy link
Contributor

Piezoid commented Oct 7, 2022

I'll said it: this issue is waiting for python2 support to be removed.

If you want to keep a legacy python2 installation you need to stay on a stable release that support it. (v0.10)

While trying to have a look I realized that I can no longer easily install python2 on my dev machine and pi. This is probably the reason that no one will tackle this, even if the fix might be easy to implement.

I've been running klipper on python3 since April 2021 with minimal modifications. Since then, support has been added to klipper master in the wake of the v0.10 release. As of October 4, 2021, klipper runs without modification on python3. I believe it will be made official with the v0.11 release.
MainsailOS is defaulting to Python3 since August 2021 and KIAUH added experimental support in v4. By now, it should be easy to use a python3 installation. I think that this should be recommended when following the development updates of klipper.

@DX94-Quas
Copy link

DX94-Quas commented Jan 16, 2023

I got an error when using uppercase letters, got this on the log:

Traceback (most recent call last):
  File "~/klipper/klippy/extras/virtual_sdcard.py", line 178, in _load_file
    fname = files_by_lower[fname.lower()]
KeyError: 'ce3_polea mod 5.gcode'
Unable to open file

the original name of the file is CE3_polea mod 5.gcode, I am using KIAUH to install, with python3

@mbravorus
Copy link

Same occurrence - sliced an STL from a file which had Chinese characters in the name, and this happens:

Internal error on command:"SDCARD_PRINT_FILE"
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/gcode.py", line 198, in _process_commands
    handler(gcmd)
  File "/home/pi/klipper/klippy/gcode.py", line 135, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 150, in cmd_SDCARD_PRINT_FILE
    self._load_file(gcmd, filename, check_subdirs=True)
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 187, in _load_file
    gcmd.respond_raw("File opened:%s Size:%d" % (filename, fsize))
  File "/home/pi/klipper/klippy/gcode.py", line 224, in respond_raw
    cb(msg)
  File "/home/pi/klipper/klippy/gcode.py", line 446, in _respond_raw
    os.write(self.fd, (msg+"\n").encode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 12: ordinal not in range(128)
Transition to shutdown state: Internal error on command:"SDCARD_PRINT_FILE"
Dumping gcode input 0 blocks

in fact, this is not the only place where things break - even after changing the gcode file name on the rPi host, it still refused to print, bailing out like this:

Internal Error on WebRequest: gcode/script
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/webhooks.py", line 256, in _process_request
    func(web_request)
  File "/home/pi/klipper/klippy/webhooks.py", line 425, in _handle_script
    self.gcode.run_script(web_request.get_str('script'))
  File "/home/pi/klipper/klippy/gcode.py", line 216, in run_script
    self._process_commands(script.split('\n'), need_ack=False)
  File "/home/pi/klipper/klippy/gcode.py", line 198, in _process_commands
    handler(gcmd)
  File "/home/pi/klipper/klippy/gcode.py", line 135, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 150, in cmd_SDCARD_PRINT_FILE
    self._load_file(gcmd, filename, check_subdirs=True)
  File "/home/pi/klipper/klippy/extras/virtual_sdcard.py", line 187, in _load_file
    gcmd.respond_raw("File opened:%s Size:%d" % (filename, fsize))
  File "/home/pi/klipper/klippy/gcode.py", line 224, in respond_raw
    cb(msg)
  File "/home/pi/klipper/klippy/gcode.py", line 446, in _respond_raw
    os.write(self.fd, (msg+"\n").encode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 12: ordinal not in range(128)
Requested toolhead position at shutdown time 77291.848183: (5.0, 170.0, 109.68693354800938)

which from Fluidd looks like file is accepted and starts printing, but nothing is actually happening on the printer side

this is with

klipper v0.11.0-66-g4671cf2d
fluidd v1.23.0
moonraker v0.7.1-806-ga154c5f

 $ cat /etc/debian_version
10.13
$ uname -a
Linux octopi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux

the system has fully functional python3, but the default one (and the one in klippy-env) is still python 2.7.16

@vladimir-poleh
Copy link

in fact, this is not the only place where things break - even after changing the gcode file name on the rPi host, it still refused to print

It seems that generated gcode contains Chinese characters in comments and it produces this error.
You need to use Python 3 for the Klipper.

@Neko-vecter
Copy link
Contributor

I think if the file name that contains the characters that not in ascii will cause this issue.
Currently possible solutions is migration Klipper to python3.

@Murat65536
Copy link

How do I change from Klipper Python 2 to Klipper Python 3?

@Piezoid
Copy link
Contributor

Piezoid commented May 7, 2023

How do I change from Klipper Python 2 to Klipper Python 3?

@Murat65536
Since you're asking, the smoothest course of action for you would likely be reinstalling Klipper using KIAUH and select Python 3 when asked:
###### Select Python version:

The manual way is to recreate Klipper's python virtual environment. Something in the lines of:

cd
mv klippy-env klippy-env-py2
python3 -m venv klippy-env
./klippy-env/bin/pip install -r ./klipper/scripts/klippy-requirements.txt
sudo systemctl restart klipper

This relies on /etc/systemd/system/klipper.service invoking the new python interpreter from the environment ($HOME/klippy-env/bin/python)
This is highly dependent on how Klipper was installed on your system.

@Murat65536
Copy link

How do I change from Klipper Python 2 to Klipper Python 3?

@Murat65536 Since you're asking, the smoothest course of action for you would likely be reinstalling Klipper using KIAUH and select Python 3 when asked: ###### Select Python version:

The manual way is to recreate Klipper's python virtual environment. Something in the lines of:

cd
mv klippy-env klippy-env-py2
python3 -m venv klippy-env
./klippy-env/bin/pip install -r ./klipper/scripts/klippy-requirements.txt
sudo systemctl restart klipper

This relies on /etc/systemd/system/klipper.service invoking the new python interpreter from the environment ($HOME/klippy-env/bin/python) This is highly dependent on how Klipper was installed on your system.

@Piezoid
I attempted to preform the actions but the error is still there. Even when there are no abnormal characters, the error does not go away. Is there anything that I can do?

@iqubik
Copy link

iqubik commented Jul 16, 2023

Cant print file with russian Exclude object names.
123_0.6n_PLA_29s.zip
Print is stop in start on delta flsun q5.

@StefanIGit
Copy link

Same here with german and named objects from Prusaslicer 2.7.1

EXCLUDE_OBJECT_DEFINE NAME=Körper1_stl CENTER=117.500,117.500 POLYGON=[[132.500,132.500],[102.500,132.500],[102.500,102.500],[132.500,102.500]]

error from klippy

Starting SD card print (position 0)
virtual_sdcard dispatch
Traceback (most recent call last):
  File "/home/stefan/klipper/klippy/extras/virtual_sdcard.py", line 264, in work_handler
    self.gcode.run_script(line)
  File "/home/stefan/klipper/klippy/gcode.py", line 229, in run_script
    self._process_commands(script.split('\n'), need_ack=False)
  File "/home/stefan/klipper/klippy/gcode.py", line 213, in _process_commands
    self._respond_error(str(e))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 47: ordinal not in range(128)
Exiting SD card print (position 55053)

Klippy.log-and-gcode.zip

@tinyboxxx
Copy link

I think it's solved after reinstalling Klipper using KIAUH and select Python 3.

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

No branches or pull requests