Closed e71828 closed 2 years ago
ubuntu@plum:~$ chmod +x mouse.py
ubuntu@plum:~$ ./mouse.py
Traceback (most recent call last):
File "./mouse.py", line 5, in <module>
success = pyspacemouse.open()
File "/home/ubuntu/.local/lib/python3.8/site-packages/pyspacemouse/pyspacemouse.py", line 656, in open
all_devices = list_devices()
File "/home/ubuntu/.local/lib/python3.8/site-packages/pyspacemouse/pyspacemouse.py", line 598, in list_devices
hid = Enumeration()
File "/home/ubuntu/.local/lib/python3.8/site-packages/easyhid/easyhid.py", line 366, in __init__
self.device_list = _hid_enumerate(vid, pid)
File "/home/ubuntu/.local/lib/python3.8/site-packages/easyhid/easyhid.py", line 428, in _hid_enumerate
start = hidapi.hid_enumerate(vendor_id, product_id)
File "/home/ubuntu/.local/lib/python3.8/site-packages/cffi/api.py", line 912, in __getattr__
make_accessor(name)
File "/home/ubuntu/.local/lib/python3.8/site-packages/cffi/api.py", line 908, in make_accessor
accessors[name](name)
File "/home/ubuntu/.local/lib/python3.8/site-packages/cffi/api.py", line 838, in accessor_function
value = backendlib.load_function(BType, name)
AttributeError: function/symbol 'hid_enumerate' not found in library '<None>': python3: undefined symbol: hid_enumerate
I get, win10 only installed the interface,no module or lib found. could please the url for easyhid
lib.
sudo apt install libhidapi-dev
, thanks.
Does it work right now?
Yes, It worked. Thanks.
Btw, for windows, the error could be solved?
I tested it two years ago, and if I remember correctly, the Windows version didn't work for me, but since the primary goal was to make it work on Linux, I didn't bother with it further.
If I'm looking at the easyhid
source code correctly. The library is trying to find hidapi.dll
Look at it there on line 53
I have also updated readme with a better install process. But I have not tested it yet. Could you please try it? @e71828
ubuntu@plum:~$ pip show easyhid
Name: easyhid
Version: 0.0.10
Summary: A simple interface to the HIDAPI library.
Home-page: http://github.com/ahtn/python-easyhid
Author: jem
Author-email: jem@seethis.link
License: MIT
Location: /home/ubuntu/.local/lib/python3.8/site-packages
Requires: cffi
Required-by:
ubuntu@plum:~$ apt list libhidapi-dev
Listing... Done
libhidapi-dev/focal,now 0.9.0+dfsg-1 arm64 [installed]
ubuntu@plum:~$ uname -a
Linux plum 5.4.0-1070-raspi #80-Ubuntu SMP PREEMPT Thu Sep 8 15:35:01 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
ubuntu@plum:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
ubuntu@plum:~$ ./m
mouse.py ms5837-python/
ubuntu@plum:~$ vim mouse.py
ubuntu@plum:~$ ls
PCA9685.py catkin_ws ina226.py openocd pigpio-master ser_with.py socket_server.py tcp_serial_redirect.py
SSD1306 emio_ws mouse.py openocd.cfg rpi-backup servo_demo.c stm32flash-0.6 temp_DHT11.py
USART.axf hello ms5837-python pi_ina226 ser_read.py socket_client.py stm32flash-0.6.tar.gz test_mouse.py
ubuntu@plum:~$ vim mouse.py
ubuntu@plum:~$ python3 mouse.py
Traceback (most recent call last):
File "mouse.py", line 2, in <module>
import pyspacemouse
ModuleNotFoundError: No module named 'pyspacemouse'
ubuntu@plum:~$ pip install pyspacemouse
Collecting pyspacemouse
Using cached pyspacemouse-1.0.3-py3-none-any.whl (10 kB)
Requirement already satisfied: easyhid in ./.local/lib/python3.8/site-packages (from pyspacemouse) (0.0.10)
Processing ./.cache/pip/wheels/5e/5d/01/3083e091b57809dad979ea543def62d9d878950e3e74f0c930/typing-3.7.4.3-py3-none-any.whl
Requirement already satisfied: cffi in ./.local/lib/python3.8/site-packages (from easyhid->pyspacemouse) (1.15.1)
Requirement already satisfied: pycparser in ./.local/lib/python3.8/site-packages (from cffi->easyhid->pyspacemouse) (2.21)
Installing collected packages: typing, pyspacemouse
Successfully installed pyspacemouse-1.0.3 typing-3.7.4.3
ubuntu@plum:~$ python3 mouse.py
SpaceMouse Compact found
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
^CTraceback (most recent call last):
File "mouse.py", line 10, in <module>
time.sleep(0.01)
KeyboardInterrupt
ubuntu@plum:~$
ubuntu@plum:~$ ll /dev/hidraw0
crw-rw-r-- 1 root plugdev 237, 0 Sep 27 00:40 /dev/hidraw0
ubuntu@plum:~$ cat /etc/udev/rules.d/
70-snap.snapd.rules 99-hidraw-permissions.rules
ubuntu@plum:~$ cat /etc/udev/rules.d/99-hidraw-permissions.rules
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev"
ubuntu@plum:~$ groups
ubuntu adm tty kmem dialout cdrom floppy sudo audio dip video plugdev netdev lxd i2c
if you are not in the group plugdev, need the scripts following:
ubuntu@plum:~$ sudo usermod -aG plugdev $USER
ubuntu@plum:~$ newgrp plugdev
ubuntu@plum:~$
HID
= C:\Users\admin\Documents\Hardware\hidapi\x64
PATH
= %PATH%;%HID%
Excellent, so now is everything working?
Could you please add a pull request with a better installation process?
Might I ask you in which project do you want to use this library? My motivation was in controlling my computer (apps) using this SpaceMouse. Especially for Inkscape - moving canvas and rotating objects.
robot motion control
That sounds nice 😍
So, is everything working correctly right now, might I close this issue?