estoy siguiendo el tutorial (http://pyusb.sourceforge.net/docs/1.0/tutorial.html)pitón usb.core importación pyusb no funciona
estoy en windows xp sp3, mi Python es la versión 2.7 y he descargado e instalado el pyusb-1.0.0-a1.zip
y libusb-win32-bin-1.2.4.0.zip
import usb
funciona bien
pero
import usb.core
no funciona en absoluto
dice
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
alguna solución?
gracias!
p.s. "de núcleo importación USB" esto hace
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
código fuente completo está aquí
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)
cambio el directorio a escritorio, nombre a usb2.py dice Traceback (última llamada más reciente): Archivo "C:/Documents and Settings/kty1104/Desktop/usb2.py", línea 3 , en dev = usb.core.find (idVendor = 0x1516, idProduct = 0x8628) NameError: name 'usb' no está definido –
gracias funciona bien ahora es normal que "import usb" no funcione pero "import usb .core "funciona? –
Intente abrir el shell interactivo de Python (o mejor aún instale y use [IPython] (http://ipython.scipy.org)) y haga: 'import usb', next' help (usb) '(o' usb? 'In IPython), busque la línea 'FILE' y compruebe si el módulo usb está en una ruta determinada (se debe tener un directorio llamado' usb * 'con al menos __init__.py file y' core.py' file). – Xaerxess