When trying to read from Dymo USB scale, I get Error: hid.HIDException: unable to open device

243 Views Asked by At

I am trying to use the hid package in Python to read from a Dymo USB scale. The code I am using comes from this Gist and it works on my Mac. However, when I run the code (which launches through a NodeJS process) on my Windows machine, I get this error:

    ChildProcess._handle.onexit @ node:internal/child_process:291
C:\Users\cody\Documents\scalereader\dist\utils\dymo.utils.js:56 Error: hid.HIDException: unable to open device
    at PythonShell.parseError (C:\Users\cody\Documents\scalereader\node_modules\python-shell\index.js:295:21)
    at terminateIfNeeded (C:\Users\cody\Documents\scalereader\node_modules\python-shell\index.js:190:32)
    at ChildProcess.<anonymous> (C:\Users\cody\Documents\scalereader\node_modules\python-shell\index.js:182:13)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)
    ----- Python Traceback -----
    File "C:\Users\cody\Documents\scalereader\dist\utils\dymo.py", line 64, in <module>
      main()  # Uncomment to execute the python operation.
    File "C:\Users\cody\Documents\scalereader\dist\utils\dymo.py", line 14, in main
      dev = hid.Device(vid=2338, pid=32771)
    File "C:\Users\cody\AppData\Local\Programs\Python\Python310\lib\site-packages\hid\__init__.py", line 132, in __init__
      raise HIDException('unable to open device')
(anonymous) @ C:\Users\cody\Documents\scalereader\dist\utils\dymo.utils.js:56
(anonymous) @ index.ts:58
terminateIfNeeded @ index.ts:58
(anonymous) @ index.ts:58
emit @ node:events:527
ChildProcess._handle.onexit @ node:internal/child_process:291
index.js:5 Uncaught (in promise) Error: hid.HIDException: unable to open device
    at PythonShell.parseError (C:\Users\cody\Documents\scalereader\node_modules\python-shell\index.js:295:21)
    at terminateIfNeeded (C:\Users\cody\Documents\scalereader\node_modules\python-shell\index.js:190:32)
    at ChildProcess.<anonymous> (C:\Users\cody\Documents\scalereader\node_modules\python-shell\index.js:182:13)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)
    ----- Python Traceback -----
    File "C:\Users\cody\Documents\scalereader\dist\utils\dymo.py", line 64, in <module>
      main()  # Uncomment to execute the python operation.
    File "C:\Users\cody\Documents\scalereader\dist\utils\dymo.py", line 14, in main
      dev = hid.Device(vid=2338, pid=32771)
    File "C:\Users\cody\AppData\Local\Programs\Python\Python310\lib\site-packages\hid\__init__.py", line 132, in __init__
      raise HIDException('unable to open device')
parseError @ index.ts:58
terminateIfNeeded @ index.ts:58
(anonymous) @ index.ts:58
emit @ node:events:527
ChildProcess._handle.onexit @ node:internal/child_process:291
Promise.then (async)
step @ index.js:6
(anonymous) @ index.js:7
__awaiter @ index.js:3
getDymoData @ index.ts:53
(anonymous) @ index.ts:19

Anyone have any ideas on how to troubleshoot this?

0

There are 0 best solutions below