I am following the tutorial(http://pyusb.sourceforge.net/docs/1.0/tutorial.html)
I am on windows xp sp3, my python version is 2.7 and I downloaded and installed the pyusb-1.0.0-a1.zip
and libusb-win32-bin-1.2.4.0.zip
import usb
works fine
but
import usb.core
doesn't working at all
it says
Traceback (most recent call last):
File "D:\py\usb.py", line 1, in <module>
from usb import core
File "D:\py\usb.py", line 1, in <module>
from usb import core
ImportError: cannot import name core
any solution?
thanks!
p.s. "from usb import core" this make
Traceback (most recent call last):
File "D:\py\usb.py", line 1, in <module>
from usb import core
File "D:\py\usb.py", line 1, in <module>
from usb import core
ImportError: cannot import name core
full source code is here
from usb import core
#find device
dev = usb.core.find(idVendor=0x1516, idProduct=0x8628)
#found?
if dev is None :
raise ValueError('device not found')
#set the active config. with no args, the first config will be the active one
dev.set_configuration()
#get an end point instance
ep = usb.util.find_descriptor(
dev.get_interface_altsetting(), #first interface
#match the first Out Endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_OUT)
assert ep is not None
while(1):
ep.write(0x5553424350DDBC880000000000000600000000000000000000000000000000)
ep.write(0x5553425350ddbc880000000000)
In both cases error is:
Traceback (most recent call last):
File "D:\py\usb.py", line 1, in <module>
which means it has file usb.py
in PATH
earlier (probably in .
which is D:\py\
in this case) than path to python modules.
Did you install this module properly? Try rename this usb.py
file to something else, you'll see if the error becomes "ImportError: No module named usb". Also check Python install path (something like C:\Python27\
) for usb folder i.e. <python_path>\lib\site-packages\usb\core.py
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With