An error occurred when executing the following script using pyusb.
import usb.core
import usb.util
import sys
dev = usb.core.find(idVendor=0x1234, idProduct=0x1234)
if dev is None:
raise ValueError('Device not found')
print(dev)
dev.set_configuration()
The error content is as follows.
aise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy
I was able to get and print the correct Device object, but I got a problem with the configuration() part of the last line.
how can i solve this problem
[Environment]
python3
pyusb
kali linux
libusb-1.0-0:arm64
Related
I am trying to install the Text add-on (version 0.7.3) for Orange (version 3.23) on my Win10, but I am getting the following error during the building "ufal_udpipe":
Command failed: python python -m pip install --constraint 'C:\Users\Jakub\AppData\Local\Temp\tmpb4fneogu.txt' Orange3-Text exited with non zero status.
ERROR: Command errored out with exit status 1: 'C:\Users\Jakub\AppData\Local\Orange\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jakub\\AppData\\Local\\Temp\\pip-install-r71cit89\\ufal.udpipe\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jakub\\AppData\\Local\\Temp\\pip-install-r71cit89\\ufal.udpipe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Jakub\AppData\Local\Temp\pip-record-gtt8e801\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
I also tried to install Microsoft Visual C++, because it´s required in the log, but the problem is the same after the installation.
I tried to install add-on throught the Anaconda Prompt:
conda config --add channels conda-forge
conda install orange3-text
This process failed, because:
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::commonmark-0.9.0-py_0'.
CondaError: Cannot link a source that does not exist. C:\Users\Jakub\Miniconda3\Scripts\conda.exe
Running `conda clean --packages` may resolve your problem.
Attempting to roll back.
Rolling back transaction: done
The result of conda clean command is following:
Traceback (most recent call last):
File "C:\Users\Jakub\Miniconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\cli\main.py", line 112, in main
from ..exceptions import conda_exception_handler
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\exceptions.py", line 18, in <module>
from .common.io import timeout
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\common\io.py", line 28, in <module>
from .._vendor.tqdm import tqdm
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\__init__.py", line 8, in <module>
from ._tqdm import tqdm
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\_tqdm.py", line 13, in <module>
from ._utils import _supports_unicode, _environ_cols_wrapper, _range, _unich, \
File "C:\Users\Jakub\Miniconda3\lib\site-packages\conda\_vendor\tqdm\_utils.py", line 31, in <module>
colorama.init()
AttributeError: module 'colorama' has no attribute 'init'
Reinstall of Orange and Anaconda didn´t help.
Full extract of logs is here: Google Disk
Thank you for your help!
Jakub
I encountered just the first line of your error. I checked if I had python and anaconda installed properly or not (and I had). I then kept trying to install and in the 4th go it installed without an issue- now my guess is maybe network issues caused the error to occur.
Another thing suggested to me by their support was- "Yes, we are aware of the issue. Somewhere in the process we accidentally disabled the necessary setting. Go to Options - Settings, find the Add-ons tab and select 'Install add-ons with conda'. This should install Text successfully."
Okay, so I found the issue fix (at least for me - comment if it works for you).
How to fix it:
Download Colorama
Copy the "Colorama" from the download then replace the folder named "colorama" in C:\Program Files\Anaconda3\Lib\site-packages
I suspect this issue occurs because of (issue 8842)
I am unable to run tensorboard, and get the message:
bad interpreter: No such file or directory
Steps to reproduce:
Installed TF on Ubuntu, using a virtenv, and pip as per instructions install instructions
Confirmed TF was correctly installed by running the mnist example. Output was as expected
Attempted to run tensorboard using:
tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
Checked that this location does contain the summary files within the "test" and "train" directories
Command and error:
(tensorflow_1_4_0) js#pchome01:~$ tensorboard --logdir=/tmp/tensorflow/mnist/logs/mnist_with_summaries/
bash: /home/js/tensorflow_1_4_0/bin/tensorboard: /home/js/tensorflow_1_3/bin/python3: bad interpreter: No such file or directory
In my virtenv folder for tensorflow_1_4_0, a tensorboard script exists:
#!/home/js/tensorflow_1_3/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from tensorboard.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
When I run the following from the terminal, no errors are reported:
from tensorboard.main import main
Thank you
Just spotted my silly mistake and posting the resolution in case others encounter this.
The meaning of the error message is that the interpreter of the code (in this case python3) cannot be found.
The first line of the tensorboard script:
#!/home/js/tensorflow_1_3/bin/python3
This tells the compiler to look for python3 at this location, however this path is incorrect and the virtual environment is actually called tensorflow_1_4_0.
Therefore changing this line to the following fixed the error:
#!/home/js/tensorflow_1_4_0/bin/python3
here see what happened
when I run the above command cmd I get an error while installing. As you can see in the above image.
s.connect((base64.b64decode(rip),17620)
I get syntax error: invalid token in line 191
and it is also giving me problems on some other modules also.
s.connect((base64.b64decode(rip),17620)
I get syntax error: invalid token in line 191
(I ran into this myself using jupyter notebook)
As you are using python 3 you don't need to install URL lib as it is part of core https://github.com/python/cpython/tree/3.6/Lib/urllib/
It's submodules are restructured so you need to change python 2 code like
import urllib
...
urllib.urlopen
into
import urllib.request
...
urllib.request.urlopen
I was looking for some documetation on pyusb . Found this link and tried to use Lennart Renegro's answer.
import usb in python shell on IDLE gave me the following error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import usb
ImportError: No module named 'usb'
However, I ran this program using python first.py on bash:
import usb
dev = usb.core.find(idVendor = 0xfffe, idProduct = 0x0001)
if dev is None:
raise ValueError('Device not found')
dev.set_configuration()
cfg = dev.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_setting = usb.control.get_interface(interface_number)
intf = usb.util.find_descriptor(cfg, bInterfaceNumber = interface_number, bAlternateSetting = alternate_setting)
ep = usb.util.find.descriptor(intf, custom_match = lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT)
assert ep is not None
ep.write('test')
and bash return the following error(which I was expecting because I hadn't connected any usb devices atm):
Traceback (most recent call last):
File "first.py", line 6, in <module>
raise ValueError('Device not found')
ValueError: Device not found
What is happening here? And how do I read those docs?
Summarizing the discussion above, apparently the python versions of IDLE and the default python shell are different. You installed pyusb for python 2.7.5, while you want to use it on IDLE which runs python 3.3.2.
To fix this problem, either
install pyusb for python 3.3.2
make sure to use python 2.7.5 with IDLE. For the latter you can have a look at the question #justhalf pointed to: Python IDLE: Change Python Version
I am learning to use twisted (latest 12.3.0 release), as a way to do some simple server side processing for a mobile app.
My first assigment is essentially to run a 'tail' command on a logs file and deliver the postprocessed found lines to the mobile app. That should be easy...
Now in the docs on the TwistedMatrix site there is a 'Using Processes' page, where I got the following code:
from twisted.internet import protocol, utils, reactor
from twisted.python import failure
from cStringIO import StringIO
class CommandRunner(protocol.Protocol):
#command = "ls /"
command = "tail -n 100 /var/log/system.log"
def connectionMade(self):
output = utils.getProcessOutput(self.command)
output.addCallbacks(self.writeResponse, self.noResponse)
def writeResponse(self, resp):
self.transport.write(resp)
self.transport.loseConnection()
def noResponse(self, err):
print err
self.transport.write("Houston, we have an error!\n")
self.transport.loseConnection()
if __name__ == '__main__':
f = protocol.Factory()
f.protocol = CommandRunner
reactor.listenTCP(10999, f)
reactor.run()
It is 99.9% identical to the published code snippet under the 'Doing it the Easy Way'. The only change is the shell command that twisted should execute (on my Mac I do not seem to have the fortune command).
After launching the sample code when I try to connect on the 10999 port from a second terminal with telnet I get this error:
[Failure instance: Traceback (failure with no frames): : got stderr: 'Upon
execvpe tail -n 100 /var/log/system.log [\'tail -n 100
/var/log/system.log\'] in environment id 4315532016\n:Traceback (most
recent call last):\n File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.6-intel.egg/twisted/internet/process.py",
line 420, in _fork\n executable, args, environment)\n File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.3.0-py2.7-macosx-10.6-intel.egg/twisted/internet/process.py",
line 466, in _execChild\n os.execvpe(executable, args,
environment)\n File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 353, in execvpe\n _execvpe(file, args, env)\n File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 368, in _execvpe\n func(file, *argrest)\nOSError: [Errno 2] No
such file or directory\n']
I do not see any obvious reason why the code should file with a [Errno 2] No such file or directory\n'] error..
Tia
The program you want to run is "tail". You want to pass it several arguments: "-n", "100", and "/var/log/system.log".
Instead, what your code does is run the program "tail -n 100 /var/log/system.log", which presumably does not exist on your system (I wouldn't expect it to).
The proper use of getProcessOutput is to pass the program separately from the argument list:
getProcessOutput("tail", ["-n", "100", "/var/log/system.log"])