File2 is not a valid CodeChannel - Part Deux
-
I did not want to hijack Ant1's previous thread so I have created a new one with a similar problem. All I am trying to do is run the examples in GitHub https://github.com/Duet3D/dsf-python/tree/main/examples, specifically the subscribe to object model example, and I receive the same error "File2 is not a valid CodeChannel".
My setup:
Duet 6HC 3.5.1 in SBC mode with a Raspberry Pi 5 running the latest Duet Bookworm imageI have performed the following (per the "pip won't install dsf-python-3.5.1rc1 thread"):
pi@A1000-1:~/.local/lib/python3.11/site-packages $ sudo pip3 install --break-system-packages --pre dsf-python Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: dsf-python in /usr/local/lib/python3.11/dist-packages (3.5.1rc1) Requirement already satisfied: python-dateutil in /usr/local/lib/python3.11/dist-packages (from dsf-python) (2.9.0.post0) Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil->dsf-python) (1.16.0) WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv pi@A1000-1:~/.local/lib/python3.11/site-packages $
From the examples folder, I have been able to run, without issue:
custom_http_endpoint.py
custom_m_codes.py
send_simple_code.pyWhen I try to run:
subscribe_object_model.pyI get:
/bin/python /home/pi/Alphamated/controller/sub.py Traceback (most recent call last): File "/home/pi/Alphamated/controller/sub.py", line 31, in <module> subscribe() File "/home/pi/Alphamated/controller/sub.py", line 18, in subscribe object_model = subscribe_connection.get_object_model() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/connections/subscribe_connection.py", line 43, in get_object_model object_model = self.receive(ObjectModel) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/connections/base_connection.py", line 83, in receive return cls.from_json(json.loads(json_string)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 87, in from_json return cls()._update_from_json(**preserve_builtin(data)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/object_model.py", line 165, in _update_from_json super(ObjectModel, self)._update_from_json(**kwargs) File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 76, in _update_from_json setattr(self, attr_name, attr.update_from_json(json_value)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_collection.py", line 57, in update_from_json self.append(self._item_constructor().update_from_json(item_to_add)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 93, in update_from_json return self._update_from_json(**preserve_builtin(data)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/model_object.py", line 69, in _update_from_json setattr(self, json_key_snake, json_value) File "/home/pi/.local/lib/python3.11/site-packages/dsf/object_model/inputs/input_channel.py", line 132, in name self._name = CodeChannel(value) ^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/enum.py", line 717, in __call__ return cls.__new__(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/enum.py", line 1133, in __new__ raise ve_exc ValueError: 'File2' is not a valid CodeChannel
What simple thing am I missing or what typo did I perform?
The Pi is dedicated to the Duet and only has a single user. I'd like to have all packages system-wide and not have to use a venv (hence, I used the --break-system-packages option for pip install).
I am nowhere near the level of you folks on here so please type slowly so I can understand...
-
@davidjryan By looking at the traceback, it seems you have an older version of dsf-python installed for the pi user (in
/home/pi/.local/lib/python3.11/site-packages/dsf/
) so python uses this one instead of the system-wide one installed in/usr/local/lib/python3.11/dist-packages
.Try running
pip3 uninstall dsf-python
without sudo to remove it.Also, please note that an APT package has been released to install dsf-python on Debian Bookworm.
This can be installed usingsudo apt install python3-dsf-python
However, there is no change since the 3.5.1rc1 version that you have currently installed usingpip3 --break-system-packages
so you should be fine. -
@Falcounet That did it, thanks!
I had performed:
sudo apt install python3-dsf-python
but didn't include the snippet of that in my post. I guess it didn't matter since I had the older version of dsf-python installed. I do install that version via a script when setting up the Pi/Duet "out of the box". I'll update my script to use python3-dsf-python instead.Thanks again!
-
-