USBError: [Errno 13] Access denied (insufficient permissions)
Question:
This problem is old as the world. There are discussions and solutions available. It all boils down to update the rules file and give permissions. So I have followed the recipe. But I still have the same problem. here are screenshots showing I follow instructions.
Versions:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
usb.__version__ '1.0.2'
Error:
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)
Rules. file (location /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"
and strip down code:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
However, it doesn’t give me necessary permissions.
My stripped down code that still produces the error:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
The strange thing that if I start IDLE from the terminal as superuser I get permissions (terminal: sudo idle
).
Answers:
Your rules look a little bit odd. Can you remove all of them and try this instead?
SUBSYSTEM=="usb", ATTRS{idVendor}=="0683", MODE="0666"
In case someone runs into this error again, I want to add to David Grayson’s answer that you additionally have to refresh udev and unplug-and-replug the USB device. So the complete steps would be:
- Add line to udev file:
sudo echo 'UBSYSTEMS=="usb", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2201" GROUP="users", MODE="0666"' >> /etc/udev/rules.d/50-myusb.rules
where the vendor and product ID must go in hex and without the 0x
. For example lsusb
in my case produced Bus 001 Device 042: ID c251:2201 Keil Software, Inc. LASER Driver IJS
and so my vendor ID is c251
and product ID is 2201
.
- Refresh udev
sudo udevadm control --reload-rules && sudo udevadm trigger
- Disconnect and re-connect the USB device.
This worked for me in Ubuntu 20.04 running Python 3.8.10.
if you know what you’re doing you can "sudo pip" install usb packages and then run python with sudo
user171780 post worked for me after I added an "S" and a "," the code block.. re-posting there summary with corrections, worked for me in Ubuntu 20.04.4 LTS
python 3.10.4
In case someone runs into this error again, I want to add to David Grayson’s answer that you additionally have to refresh udev and unplug-and-replug the USB device. So the complete steps would be:
Add line to udev file:
sudo echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2201", GROUP="users", MODE="0666"' >> /etc/udev/rules.d/50-myusb.rules
where the vendor and product ID must go in hex and without the 0x. For example lsusb in my case produced Bus 001 Device 042: ID c251:2201 Keil Software, Inc. LASER Driver IJS and so my vendor ID is c251 and product ID is 2201.
Refresh udev
sudo udevadm control --reload-rules && sudo udevadm trigger
Disconnect and re-connect the USB device.
Following @joe-bob’s step-by-step answer helped me configure python’s hdi package. Only two things that I would like to add it:
- Changing the append to
tee
helped me due to sudo needs:
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1189", ATTRS{idProduct}=="8890", GROUP="users", MODE="0666"' | sudo tee /etc/udev/rules.d/50-myusb.rules
- The vendor id and product id shown in the
hdi
package are different than the ones shown in lusb
note: my vendor and products ids are different because my code reads data from a CH57x device
you can add a udev rule to allow your user account to access the USB device without needing elevated privileges. Here’s an example rule you can add:
1)Create a new file in the /etc/udev/rules.d/ directory called 99-usb-printer.rules:
sudo nano /etc/udev/rules.d/99-usb-printer.rules
2)Add the following line to the file to grant permissions for the Epson TM-T88V printer based on its vendor ID and product ID:
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0202", MODE="0666"
3)Save and close the file.
4)Reload the udev rules to apply the changes:
sudo udevadm control --reload-rules
finally unplug the usb device and plug again.
This problem is old as the world. There are discussions and solutions available. It all boils down to update the rules file and give permissions. So I have followed the recipe. But I still have the same problem. here are screenshots showing I follow instructions.
Versions:
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
usb.__version__ '1.0.2'
Error:
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)
Rules. file (location /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"
and strip down code:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
However, it doesn’t give me necessary permissions.
My stripped down code that still produces the error:
import usb.core
import usb.util
dev = usb.core.find(idVendor=0x0683, idProduct=0x4108)
dev.reset()
The strange thing that if I start IDLE from the terminal as superuser I get permissions (terminal: sudo idle
).
Your rules look a little bit odd. Can you remove all of them and try this instead?
SUBSYSTEM=="usb", ATTRS{idVendor}=="0683", MODE="0666"
In case someone runs into this error again, I want to add to David Grayson’s answer that you additionally have to refresh udev and unplug-and-replug the USB device. So the complete steps would be:
- Add line to udev file:
sudo echo 'UBSYSTEMS=="usb", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2201" GROUP="users", MODE="0666"' >> /etc/udev/rules.d/50-myusb.rules
where the vendor and product ID must go in hex and without the 0x
. For example lsusb
in my case produced Bus 001 Device 042: ID c251:2201 Keil Software, Inc. LASER Driver IJS
and so my vendor ID is c251
and product ID is 2201
.
- Refresh udev
sudo udevadm control --reload-rules && sudo udevadm trigger
- Disconnect and re-connect the USB device.
This worked for me in Ubuntu 20.04 running Python 3.8.10.
if you know what you’re doing you can "sudo pip" install usb packages and then run python with sudo
user171780 post worked for me after I added an "S" and a "," the code block.. re-posting there summary with corrections, worked for me in Ubuntu 20.04.4 LTS
python 3.10.4
In case someone runs into this error again, I want to add to David Grayson’s answer that you additionally have to refresh udev and unplug-and-replug the USB device. So the complete steps would be:
Add line to udev file:
sudo echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2201", GROUP="users", MODE="0666"' >> /etc/udev/rules.d/50-myusb.rules
where the vendor and product ID must go in hex and without the 0x. For example lsusb in my case produced Bus 001 Device 042: ID c251:2201 Keil Software, Inc. LASER Driver IJS and so my vendor ID is c251 and product ID is 2201.
Refresh udev
sudo udevadm control --reload-rules && sudo udevadm trigger
Disconnect and re-connect the USB device.
Following @joe-bob’s step-by-step answer helped me configure python’s hdi package. Only two things that I would like to add it:
- Changing the append to
tee
helped me due to sudo needs:
echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1189", ATTRS{idProduct}=="8890", GROUP="users", MODE="0666"' | sudo tee /etc/udev/rules.d/50-myusb.rules
- The vendor id and product id shown in the
hdi
package are different than the ones shown inlusb
note: my vendor and products ids are different because my code reads data from a CH57x device
you can add a udev rule to allow your user account to access the USB device without needing elevated privileges. Here’s an example rule you can add:
1)Create a new file in the /etc/udev/rules.d/ directory called 99-usb-printer.rules:
sudo nano /etc/udev/rules.d/99-usb-printer.rules
2)Add the following line to the file to grant permissions for the Epson TM-T88V printer based on its vendor ID and product ID:
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0202", MODE="0666"
3)Save and close the file.
4)Reload the udev rules to apply the changes:
sudo udevadm control --reload-rules
finally unplug the usb device and plug again.