Win10 install pyusb

A recent task needs to use usb for information interaction, mainly using the pyusb library, and simply record the installation process.

1. Installation

I am using anaconda, and the installation steps are as follows:

1. Open the anaconda prompt;

2. Activate the environment (the environment I use is called pytorch): activate pytorch

3. Install pyusb: execute the command

pip install pyusb

2. Testing and problem solving

After the installation is complete, test whether the installation is successful according to the code provided in the official document .

Use pycharm to create a new python file and type the following code:

import usb.core
import usb.util

#find your device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

An error is reported after the result is run:

Solution:

Need to download libusb!

First, open the download link and choose to download the compressed package of libusb-1.0.24.7z

Open the compressed package, select MinGW64\dll\libusb-1.0.dll, and copy it to the Lib folder under C:\Windows\System32 and Conda environment.

For example, I created a new environment named pytorch under Conda, so copy the file to D:\Anaconda3\envs\pytorch\Lib.

Then run the detection program here, you can find the problem and solve it!

Other systems need to be copied to another path, as detailed in the original text .

 

Reference link:

https://blog.csdn.net/qq_36272641/article/details/86244596

 

Guess you like

Origin blog.csdn.net/ting_qifengl/article/details/114299247