klipper icon indicating copy to clipboard operation
klipper copied to clipboard

Internal error on command:"SDCARD_PRINT_FILE"

Open michi6383 opened this issue 4 years ago • 26 comments

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 avatar Oct 11 '21 07:10 michi6383

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.

michi6383 avatar Oct 11 '21 08:10 michi6383

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)

ontje avatar Oct 11 '21 16:10 ontje

Glad I found this... Renaming file worked

drak42 avatar Oct 13 '21 21:10 drak42

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

kolbenhans avatar Oct 15 '21 06:10 kolbenhans

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[bot] avatar Nov 19 '21 12:11 github-actions[bot]

Still existing...

michi6383 avatar Nov 23 '21 08:11 michi6383

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

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

vladimir-poleh avatar Nov 25 '21 14:11 vladimir-poleh

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: https://github.com/th33xitus/kiauh/issues/136#issuecomment-963480182

soxhi8 avatar Nov 25 '21 23:11 soxhi8

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

mvoss96 avatar Jan 15 '22 17:01 mvoss96

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

Sineos avatar Jan 15 '22 18:01 Sineos

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.

CircuitGuy avatar Feb 25 '22 04:02 CircuitGuy

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

tbb98 avatar May 13 '22 08:05 tbb98

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.

RPhilbo avatar Sep 14 '22 16:09 RPhilbo

Same thing. All software is up to date.

webhive avatar Oct 01 '22 13:10 webhive

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

jperrin72 avatar Oct 06 '22 09:10 jperrin72

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.

Piezoid avatar Oct 07 '22 13:10 Piezoid

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

DX94-Quas avatar Jan 16 '23 12:01 DX94-Quas

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

mbravorus avatar Jan 24 '23 13:01 mbravorus

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.

vladimir-poleh avatar Jan 27 '23 14:01 vladimir-poleh

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.

Neko-vecter avatar Apr 05 '23 13:04 Neko-vecter

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

Murat65536 avatar May 06 '23 21:05 Murat65536

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 avatar May 07 '23 09:05 Piezoid

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?

Murat65536 avatar May 09 '23 01:05 Murat65536

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

iqubik avatar Jul 16 '23 14:07 iqubik

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

StefanIGit avatar Dec 29 '23 18:12 StefanIGit

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

tinyboxxx avatar May 31 '24 22:05 tinyboxxx