pyhidapi icon indicating copy to clipboard operation
pyhidapi copied to clipboard

added path for hidapi.dll for windows

Open rundekugel opened this issue 3 years ago • 2 comments

I love this lib, but when I distributed my python-usb-hid script, some users can't execute it.

This added paths helped, if the pyhidapi is not installed, but a copy is distributed with the script, and the dll is also only copied in to the folder of script or lib.

rundekugel avatar Apr 19 '23 07:04 rundekugel

I would recommend changing the path environment variable to include the absolute path to where you distribute the dll as part of your script before importing the hid library.

I'm a bit hesitant to add relative paths here since that could pose a security risk in a lot of contexts.

apmorton avatar Apr 19 '23 12:04 apmorton

@rundekugel if you are distributing pyhidapi, you can probably place the .dll next to it and it should work, see https://bugs.python.org/issue43173 However, if I remember correctly, I wasn't able to make this work when using Python installed via MS Store, so there I also had to do:

if sys.platform == 'win32':
    os.add_dll_directory(os.path.dirname(os.path.abspath(__file__)))

all that is to say, I think you can solve your problem without making any changes to this lib.

ndreys avatar Feb 10 '24 18:02 ndreys