SoxNotInstalled exception raised when importing pyaudioconvert - python

enter image description hereAs can be seen in the traceback the exception occurs when pyaudioconvert is imported. How can this be fixed?
Traceback below:
Traceback (most recent call last):
File "C:\Users\320052863\PycharmProjects\Test\venv\lib\site-packages\pyaudioconvert\__init__.py", line 43, in <module>
assert(bool_which('sox'))
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/320052863/PycharmProjects/Test/hello.py", line 1, in <module>
import pyaudioconvert
File "C:\Users\320052863\PycharmProjects\Test\venv\lib\site-packages\pyaudioconvert\__init__.py", line 45, in <module>
raise SoxNotInstalled()
pyaudioconvert.SoxNotInstalled

As the error message says, you need to install SoX.
It is also listed as a requirement for pyaudioconvert.

Related

Able to start chrome from path but can't control it in pywinauto

I had tried this code:
from pywinauto import Application
app = Application().start("chrome")
but I get this error:
Traceback (most recent call last):
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 1038, in start
(h_process, _, dw_process_id, _) = win32process.CreateProcess(
pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 1052, in start
raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process "chrome"
Error returned by CreateProcess: (2, 'CreateProcess', 'The system cannot find the file specified.')
So I tried this instead:
from pywinauto import Application
app = Application().start(r"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
This launched google however, I can't control it. When I run this code:
from pywinauto import Application
app = Application().start(r"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
app.NewTab.Edit.set_text("A link")
I get the following error:
Traceback (most recent call last):
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 250, in __resolve_control
ctrl = wait_until_passes(
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
raise err
pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 379, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 261, in __resolve_control
raise e.original_exception
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
func_val = func(*args, **kwargs)
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 203, in __get_ctrl
dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\findwindows.py", line 84, in find_element
elements = find_elements(**kwargs)
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\findwindows.py", line 305, in find_elements
elements = findbestmatch.find_best_control_matches(best_match, wrapped_elems)
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\findbestmatch.py", line 536, in find_best_control_matches
raise MatchError(items = name_control_map.keys(), tofind = search_text)
pywinauto.findbestmatch.MatchError: Could not find 'NewTab' in 'dict_keys([])'
I don't understand this error at all. I had searched stack overflow and tried this code:
from pywinauto import Application
app = Application().start("chrome.exe --force-renderer-accessibility")
app.NewTab.Edit.set_text("A link")
but it yielded the same results. I got this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'app' is not defined
>>> app = Application().start("chrome.exe --force-renderer-accessibility")
Traceback (most recent call last):
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 1038, in start
(h_process, _, dw_process_id, _) = win32process.CreateProcess(
pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 1052, in start
raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process "chrome.exe --force-renderer-accessibility"
Error returned by CreateProcess: (2, 'CreateProcess', 'The system cannot find the file specified.')
>>> app.NewTab.Edit.set_text("A link")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'app' is not defined
>>> app = Application().start("chrome.exe --force-renderer-accessibility")
Traceback (most recent call last):
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 1038, in start
(h_process, _, dw_process_id, _) = win32process.CreateProcess(
pywintypes.error: (2, 'CreateProcess', 'The system cannot find the file specified.')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DEVDHRITI\AppData\Local\Programs\Python\Python310\lib\site-packages\pywinauto\application.py", line 1052, in start
raise AppStartError(message)
pywinauto.application.AppStartError: Could not create the process "chrome.exe --force-renderer-accessibility"
Error returned by CreateProcess: (2, 'CreateProcess', 'The system cannot find the file specified.')
Also I'm using python 3.10.0 so is this a bug of my version?

matplotlib python3.4.1 win7

I am using python3.4.1 in win7
And I wana use matplotlib.
but this error code has occured.
Could you help me?
>>> text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\nltk\draw\dispersion.py", line 25, in dispersion_plot
import pylab
File "C:\Python34\lib\site-packages\pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "C:\Python34\lib\site-packages\matplotlib\__init__.py", line 105, in <module>
import six
ImportError: No module named 'six'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
text4.dispersion_plot(["citizens", "democracy", "freedom", "duties", "America"])
File "C:\Python34\lib\site-packages\nltk\text.py", line 445, in dispersion_plot
dispersion_plot(self, words)
File "C:\Python34\lib\site-packages\nltk\draw\dispersion.py", line 27, in dispersion_plot
raise ValueError('The plot function requires the matplotlib package (aka pylab).'
ValueError: The plot function requires the matplotlib package (aka pylab).See
http://matplotlib.sourceforge.net/
>>>

I can't run matplotlib on python3.3

I have this code:
import random
import matplotlib.pyplot as plotttt
def simular (N):
Nd=N
c=0
while Nd>(N/2-1):
r=random.uniform(0,1)
if r<Nd/float(N):
Nd=Nd-1
else:
Nd=Nd+1
c+=1
return c
def main ():
Nmax=400
repeticiones=100
x=[]
y=[]
for j in range (2,Nmax):
promedio=0
for i in range (0,repeticiones):
promedio+=simular(j)
y.append(promedio/repeticiones)
x.append(j)
plotttt.plot (x,y,"bo")
plotttt.show()
main()
But when I try to run in through terminal the next error appears:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1519, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/matplotlib/__init__.py", line 124, in <module>
import pyparsing
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pyparsing.py", line 65, in <module>
import string.ascii_lowercase
ImportError: No module named 'string.ascii_lowercase'; string is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "simulacion.py", line 2, in <module>
import matplotlib.pyplot as plotttt
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/matplotlib/__init__.py", line 126, in <module>
raise ImportError("matplotlib requires pyparsing")
ImportError: matplotlib requires pyparsing
Vicente-Gomezs-MacBook-Pro:Python Vicente$
However no problem occurs when I run it on IDLE. Ideas?

Python print last traceback only?

Consider the following code and traceback:
>>> try:
... raise KeyboardInterrupt
... except KeyboardInterrupt:
... raise Exception
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
Exception
>>>
I'd like to print only the most recent traceback (the one in which Exception was raised).
How can this be achieved?
From the above example, I'd like to print the following, as if raise Exception had been called outside the except clause.
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
Exception
The perfect question for me.
You can suppress the exception context, that is the first part of the traceback, by explicitly raising the exception from None:
>>> try:
raise KeyboardInterrupt
except:
raise Exception from None
Traceback (most recent call last):
File "<pyshell#4>", line 4, in <module>
raise Exception from None
Exception
This was formalized in PEP 409 and further improved in PEP 415. The original bug request for this was filed by myself btw.
Note that suppressing the context will not actually remove the context from the new exception. So you can still access the original exception:
try:
try:
raise Exception('inner')
except:
raise Exception('outer') from None
except Exception as e:
print(e.__context__) # inner

Custom python traceback or debug output

I have a traceback print and want to customize the last part of it.
What: The error occurred in another process and traceback lies there (as is the case in multiprocessing).
Problem: I want to have the full traceback and error report.
Similar to this code:
>>> def f():
g()
>>> def g():
raise Exception, Exception(), None ## my traceback here
>>> f()
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
f()
File "<pyshell#8>", line 2, in f
g()
File "<pyshell#11>", line 2, in g
raise Exception, Exception(), None ## my traceback starts here
my traceback appears here
my traceback appears here
Exception
Impossible "Solutions": subclass and mock-object
>>> from types import *
>>> class CostomTB(TracebackType):
pass
Traceback (most recent call last):
File "<pyshell#125>", line 1, in <module>
class CostomTB(TracebackType):
TypeError: Error when calling the metaclass bases
type 'traceback' is not an acceptable base type
>>> class CostomTB(object):
pass
>>> try: zzzzzzzzz
except NameError:
import sys
ty, err, tb = sys.exc_info()
raise ty, err, CostomTB()
Traceback (most recent call last):
File "<pyshell#133>", line 5, in <module>
raise ty, err, CostomTB()
TypeError: raise: arg 3 must be a traceback or None
I am using python 2.7.
I guess you want the full traceback stack. See this which is having very good examples python logging module.
If some confusion comes See the logging documentation.
You mentioned a separate process: if your problem is to capture the traceback in process A and show it in process B, as if the exception was actually raised in the latter, then I'm afraid there is no clean way to do it.
I would suggest to serialize the traceback in process A, send it to process B and from there raise a new exception that includes the former in its description. The result is a somewhat longer output, but it carries information about both processes stacks.
In the following example there aren't really two separate processes, but I hope it makes my point clearer:
import traceback, StringI
def functionInProcessA():
raise Exception('Something happened in A')
class RemoteException(Exception):
def __init__(self, tb):
Exception.__init__(self, "Remote traceback:\n\n%s" % tb)
def controlProcessB():
try:
functionInProcessA()
except:
fd = StringIO.StringIO()
traceback.print_exc(file=fd)
tb = fd.getvalue()
raise RemoteException(tb)
if __name__ == '__main__':
controlProcessB()
Output:
Traceback (most recent call last):
File "a.py", line 20, in <module>
controlProcessB()
File "a.py", line 17, in controlProcessB
raise RemoteException(tb)
__main__.RemoteException: Remote traceback:
Traceback (most recent call last):
File "a.py", line 12, in controlProcessB
functionInProcessA()
File "a.py", line 4, in functionInProcessA
raise Exception('Something happened in A')
Exception: Something happened in A

Categories