kalamine
kalamine copied to clipboard
Error: 'bytes' object has no attribute 'suffix'. on xkalamine install
I have upgraded to kalamine v0.36. I used the 1dk keyboard layouts before without an issue.
Now I build my own layout, but when trying to install it using the
sudo env "PATH=$PATH" xkalamine install <path/to/layout>.toml
I get the following cryptic error
File could not be parsed. Error: 'bytes' object has no attribute 'suffix'.
The .toml file is valid. I can use xkalamine apply to use it ad-hoc and I can test the layout using kalamine watch.
I am on Ubuntu 20.04 LTS.
Strange, I can’t reproduce this error here (with Ubuntu 22.04). Could you please :
- share the whole console output, from the command line to the next prompt
- share your TOML file
This is the whole output after the prompt:
$ sudo env "PATH=$PATH" xkalamine install <path/to/layout>.toml
File could not be parsed.
Error: 'bytes' object has no attribute 'suffix'.
It appears to be an issue with the parser, not Kalamine.
Since creating the issue, I downgraded Kalamine to 0.13 and it works. It could be some broken Python dependencies on my side. I do robotics research and have ROS Noetic installed; and ROS is a packaging nightmare, so this could indeed be a rare bug that only affects me, and it may be outside of your control.
I attach the layout file (it has .txt suffix since GitHub does not let me to attach a .toml file.
It could be some broken Python dependencies on my side. I do robotics research and have ROS Noetic installed; and ROS is a packaging nightmare, so this could indeed be a rare bug that only affects me, and it may be outside of your control.
How did you install kalamine? The recommend method is using pipx. See the README, which isolate dependencies. If not, give it a try after deinstalling your previous installation of kalamine.
What Python version are you using? The bytes
error is suspiciously a common Python 2 error.
python --version
I agree the pipx
trick would make it much easier to run xkalamine
with sudo
.
It appears to be an issue with the parser, not Kalamine.
This is weird : if the parser didn’t work, then kalamine watch
wouldn’t work either.
I’m tempted to think this might be something related to sudo
. Can you please try kalamine install
without sudo
to see if the parser works in this context ?
This won’t install your layout, but as xkalamine
parses the layout before trying to install it, we’ll know whether this is related to the parser or to the sudo / python environment.
The
bytes
error is suspiciously a common Python 2 error.
Oh, I didn’t know that. The Python2 trick would surprise me a bit, as all cli*.py
files have a Python3 shebang :
#!/usr/bin/env python3
However, I did drop those Python3 shebangs in non-script modules in #105. If that’s related, then version 0.22 should work and version 0.33 should not.
I can confirm the issue on a new machine. Downgrading kalamine to 0.22 fixed it.