Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.27k stars 5.27k forks source link

Internal error on command:"SDCARD_PRINT_FILE" #4794

Open michi6383 opened 2 years ago

michi6383 commented 2 years ago
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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Glad I found this... Renaming file worked

kolbenhans commented 2 years ago

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

github-actions[bot] commented 2 years ago

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.

michi6383 commented 2 years ago

Still existing...

vladimir-poleh commented 2 years ago

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

  1. Use release version v0.10
  2. Switch to Python 3
soxhi8 commented 2 years ago

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

mvoss96 commented 2 years ago

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

Sineos commented 2 years ago

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

CircuitGuy commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

Same thing. All software is up to date.

jperrin72 commented 1 year ago

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

Piezoid commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

Piezoid commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

StefanIGit commented 8 months ago

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 commented 3 months ago

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