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

List runs, but status doesn't run under Ubuntu 24.04 #7

Open
rrobinett opened this issue Sep 6, 2024 · 9 comments
Open

List runs, but status doesn't run under Ubuntu 24.04 #7

rrobinett opened this issue Sep 6, 2024 · 9 comments

Comments

@rrobinett
Copy link

root@KPH-Beelink-2:/home/wsprdaemon/lbgpsdo# python3 lbgpsdo.py list
1dd2:2210 1-3:1.0 G41043 GPS Reference Clock

root@KPH-Beelink-2:/home/wsprdaemon/lbgpsdo# python3 lbgpsdo.py status
Traceback (most recent call last):
File "/home/wsprdaemon/lbgpsdo/lbgpsdo.py", line 1469, in
args.func(args)
File "/home/wsprdaemon/lbgpsdo/lbgpsdo.py", line 1019, in command_status
for d in GPSDODevice.openall(serial = args.serial, device = args.device):
File "/home/wsprdaemon/lbgpsdo/lbgpsdo.py", line 736, in openall
yield cls(dinfo)
^^^^^^^^^^
File "/home/wsprdaemon/lbgpsdo/lbgpsdo.py", line 766, in init
self.device = hid.Device(path = dinfo['path'])
^^^^^^^^^^
AttributeError: module 'hid' has no attribute 'Device'. Did you mean: 'device'?
root@KPH-Beelink-2:/home/wsprdaemon/lbgpsdo#

@hamarituc
Copy link
Owner

It seems you have the wrong HID python package installed. Unfortunately there are two different implementations both using the same package name hid. This software expects python3-hid. Maybe you have python3-hidapi installed. In that case please try again with python3-hid.

@rrobinett
Copy link
Author

rrobinett commented Sep 6, 2024 via email

@hamarituc
Copy link
Owner

I would not recommend to install python packages globally with pip, but use the Linux distribution package manager in this case. Alternatively you may create a virtual python environment and install python packages with pip to this environment.

We first need to figure out which python package is loaded. Please open a interactive python shell an execute the following code.

import hid

print(hid.__file__)

This file should belong to the python3-hidapi package. You may confirm this with dpkg -L python3-hidapi. The file should contain lines like:

hidapi = None
library_paths = (
    'libhidapi-hidraw.so',
    'libhidapi-hidraw.so.0',
    'libhidapi-libusb.so',
    'libhidapi-libusb.so.0',
    'libhidapi-iohidmanager.so',
    'libhidapi-iohidmanager.so.0',
    'libhidapi.dylib',
    'hidapi.dll',
    'libhidapi-0.dll'
)

If not, the wrong hid package is loaded.

@rrobinett
Copy link
Author

rrobinett commented Sep 9, 2024 via email

@rrobinett
Copy link
Author

rrobinett commented Sep 9, 2024 via email

@rrobinett
Copy link
Author

rrobinett commented Sep 9, 2024 via email

@gbevan
Copy link

gbevan commented Sep 10, 2024

I use virtualenv to create an isolated python+pip-modules environment for the tool:

> ~/src/radio/gpsdo
> $ ll
total 24
drwxrwxr-x 4 ??? ??? 4096 Jul 24 09:29 ./
drwxrwxr-x 5 ??? ??? 4096 Sep  3 10:27 ../
drwxrwxr-x 4 ??? ??? 4096 Jul 24 09:27 .env/
-rw-rw-r-- 1 ??? ???   40 Jul  1  2023 .gitignore
drwxrwxr-x 4 ??? ??? 4096 Jul  1  2023 lbgpsdo/
-rwxr-xr-x 1 ??? ???   78 Jul 24 09:28 lb_watch*
(.env) > ~/src/radio/gpsdo
> $ source .env/bin/activate
(.env) > ~/src/radio/gpsdo
> $ pip list
Package Version
------- -------
hid     1.0.6
pip     24.0
(.env) > ~/src/radio/gpsdo
> $ pip freeze
hid==1.0.6

you can pin the hid module to a specific version.

works fine on Ubuntu 24.04.1:

(.env) > ~/src/radio/gpsdo
> $ lbgpsdo/lbgpsdo.py status
9FBF7EA7E6  /dev/hidraw0: SAT locked    PLL locked    Loss: 1

I have a watcher script to monitor the status:

> $ cat lb_watch 
#!/bin/bash

source .env/bin/activate

watch -d -n2 lbgpsdo/lbgpsdo.py status

@rrobinett
Copy link
Author

rrobinett commented Sep 10, 2024 via email

@hamarituc
Copy link
Owner

I 'apt removed' both hid and hidapi, verified there was no hid module, then 'apt installed' hid: @.:~/lbgpsdo$ python3 ./lbgpsdo.py status Traceback (most recent call last): File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 1469, in args.func(args) File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 1019, in command_status for d in GPSDODevice.openall(serial = args.serial, device = args.device): File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 736, in openall yield cls(dinfo) ^^^^^^^^^^ File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 766, in init self.device = hid.Device(path = dinfo['path']) ^^^^^^^^^^ AttributeError: module 'hid' has no attribute 'Device'. Did you mean: 'device'? @.:/lbgpsdo$

On Mon, Sep 9, 2024 at 3:19 PM Rob Robinett @.> wrote: And this: @.:
$ dpkg -L python3-hidapi dpkg-query: package 'python3-hidapi' is not installed Use dpkg --contents (= dpkg-deb --contents) to list archive files contents. @.:~$ dpkg -L python3-hidapi So I tried to apt install hidapi, but still got the same error: @.:/lbgpsdo$ sudo apt install python3-hidapi Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: python3-hidapi 0 upgraded, 1 newly installed, 0 to remove and 142 not upgraded. Need to get 6,480 B of archives. After this operation, 32.8 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu noble/universe amd64 python3-hidapi amd64 0.2.2-1.1build2 [6,480 B] Fetched 6,480 B in 1s (9,688 B/s) Selecting previously unselected package python3-hidapi. (Reading database ... 154049 files and directories currently installed.) Preparing to unpack .../python3-hidapi_0.2.2-1.1build2_amd64.deb ... Unpacking python3-hidapi (0.2.2-1.1build2) ... Setting up python3-hidapi (0.2.2-1.1build2) ... Scanning processes... Scanning processor microcode... Scanning linux images... Running kernel seems to be up-to-date. The processor microcode seems to be up-to-date. No services need to be restarted. No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host. @.***:/lbgpsdo$ python3 ./lbgpsdo.py status Traceback (most recent call last): File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 1469, in args.func(args) File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 1019, in command_status for d in GPSDODevice.openall(serial = args.serial, device = args.device): File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 736, in openall yield cls(dinfo) ^^^^^^^^^^ File "/home/wsprdaemon/lbgpsdo/./lbgpsdo.py", line 766, in init self.device = hid.Device(path = dinfo['path']) ^^^^^^^^^^ AttributeError: module 'hid' has no attribute 'Device'. Did you mean: 'device'? @.:~/lbgpsdo$ On Mon, Sep 9, 2024 at 3:14 PM Rob Robinett @.> wrote: > Hi, > > This is what I get: > > @.:~$ python3 > Python 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import hid > >>> > >>> print(hid.file) > /usr/lib/python3/dist-packages/hid.cpython-312-x86_64-linux-gnu.so > >>> > > On Mon, Sep 9, 2024 at 3:08 PM Mario Haustein @.> > wrote: > >> I would not recommend to install python packages globally with pip, but >> use the Linux distribution package manager in this case. Alternatively you >> may create a virtual python environment and install python packages with >> pip to this environment. >> >> We first need to figure out which python package is loaded. Please open >> a interactive python shell an execute the following code. >> >> import hid >> print(hid.file) >> >> This file should belong to the python3-hidapi package. You may confirm >> this with dpkg -L python3-hidapi. The file should contain lines like: >> >> hidapi = None >> library_paths = ( >> 'libhidapi-hidraw.so', >> 'libhidapi-hidraw.so.0', >> 'libhidapi-libusb.so', >> 'libhidapi-libusb.so.0', >> 'libhidapi-iohidmanager.so', >> 'libhidapi-iohidmanager.so.0', >> 'libhidapi.dylib', >> 'hidapi.dll', >> 'libhidapi-0.dll' >> ) >> >> If not, the wrong hid package is loaded. >> >> — >> Reply to this email directly, view it on GitHub >> <#7 (comment)>, >> or unsubscribe >> https://github.com/notifications/unsubscribe-auth/AIFAQZF26I2UGN2LZQVCEMLZVYL7DAVCNFSM6AAAAABNYEXRECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZZGIZTSOJWGA >> . >> You are receiving this because you authored the thread.Message ID: >> @.> >> > > > -- > Rob Robinett > AI6VN > @. > mobile: +1 650 218 8896 > -- Rob Robinett AI6VN @.*** mobile: +1 650 218 8896
-- Rob Robinett AI6VN @.*** mobile: +1 650 218 8896

If you uninstalled both packages in your distro, but are still getting this error message, it seems python loads a package you installed manually via pip which overrules your distribution packages. At first you have to remove the python packages globally installed via pip. There is a guideline at https://stackoverflow.com/questions/11248073/how-do-i-remove-all-packages-installed-by-pip, but I didn't try it and cannot provide any warranty for data loss or system damage. Afterwards install python3-hidapi via your distro.

Using pip is only advised inside a local python environment. Installing python packages through pip bypassing your distributions package management will mess up your system sooner or later.

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

No branches or pull requests

3 participants