micolous / pcprox

Library for pcProx USB RFID reader
GNU Lesser General Public License v3.0
21 stars 2 forks source link

AttributeError: module 'hid' has no attribute 'device' #1

Closed leitao closed 4 years ago

leitao commented 5 years ago

When I try to run it on my env, I get the following error. I am wondering if I am using the wrong hid library version (1.0.2), since it contains Device() but no device().

Traceback (most recent call last):
  File "configure.py", line 101, in <module>
    main(options.set_true, options.set_false, options.set_int, options.write_eeprom, options.debug)
  File "configure.py", line 38, in main
    dev = pcprox.open_pcprox(debug=debug)
  File "/home/root/py/pcprox.py", line 109, in open_pcprox
    dev = hid.device()
AttributeError: module 'hid' has no attribute 'device'
soorajvnair commented 5 years ago

Hey @leitao make sure you're running the program as root. sudo python3 configure.py and you should see it working normally. Also make sure you've installed all dependencies, like hidapi.

MiguelAPerez commented 5 years ago

@soorajvnair @leitao, I had to the same issue and I found changing line 137 on pcprox.py from hid.device() to hid.Device(vid=PCPROX_VENDOR, pid=PCPROX_PRODUCT). The hid library doesn't have the device function then I just commented on line 329. Hid also doesn't have the set_nonblocking anymore. If you're on Linux you can check the python dir -> /dist-packages/hid/_init_.py to see the functions. Lastly remove dev.open(PCPROX_VENDOR, PCPROX_PRODUCT) on line 138 (pcprox.py)

micolous commented 4 years ago

I think you have the wrong HID library. Unfortunately, there are many identically named hid modules on PyPI.

The set_nonblocking method is definitely there.