这个问题和世界一样古老。有可用的讨论和解决方案。这一切都归结为更新规则文件并授予权限。所以我遵循了食谱。但我仍然有同样的问题。这是显示我按照说明操作的屏幕截图。
版本:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
usb.__version__ '1.0.2'
错误:
Traceback (most recent call last):
File "/media/psf/Home/All-Projects-on-femto/LaserLab/Software/usb_4108.py", line 19, in <module>
dev.set_configuration()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 147, in managed_set_configuration
self.managed_open()
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 120, in managed_open
self.handle = self.backend.open_device(self.dev)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 786, in open_device
return _DeviceHandle(dev)
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 643, in __init__
_check(_lib.libusb_open(self.devid, byref(self.handle)))
File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 13] Access denied (insufficient permissions)
规则。文件(位置/etc/udev/rules.d/99-usbftdi.rules)
# For FTDI FT232 & FT245 USB devices with Vendor ID = 0x0403, Product ID = 0xabc
SYSFS{idProduct}=="4108", SYSFS{idVendor}=="0683", RUN+="/sbin/modprobe -q ftdi-sio product=0x4108 vendor=0x0683"
#SYSFS{idProduct}=="2450", SYSFS{idVendor}=="0683", RUN+="/sbin/modprobe -q ftdi-sio product=0x2450 vendor=0x0683"
SYSFS{idVendor}=="0683", SYSFS{idProduct}=="4108", MODE="0666"
并剥离代码:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
但是,它没有给我必要的权限。
我的精简代码仍然会产生错误:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
奇怪的是,如果我以 super 用户身份从终端启动 IDLE,我会获得权限(终端:
sudo idle
)。 最佳答案
你的规则看起来有点奇怪。你能把它们全部删除,然后试试这个吗?
SUBSYSTEM=="usb", ATTRS{idVendor}=="0683", MODE="0666"
关于python - USBError : [Errno 13] Access denied (insufficient permissions),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50625363/