I am a beginner and have a problem after installing pycaw for the audio control using python, on putting the basic initialization code for pycaw, i get the following error:-
Traceback (most recent call last):
File "c:\Users\...\volumeControl.py", line 7, in <module>
from comtypes import CLSCTX_ALL
File "C:\...\env\lib\site-packages\comtypes\__init__.py", line 375
except COMError, err:
^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
Basic initialization:-
from ctypes import cast, POINTER
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(
IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume = cast(interface, POINTER(IAudioEndpointVolume))
I tried searching for this all over the web but could not find a fix
I also trying going into the module file inside the virtual env and parenthize by putting brackets around COMError, err
But same error with other lines in code came,
Also tried reinstalling pycaw and trying to install different versions of pycaw several times but nothing fixed
How to fix this error?
I just figured out what the cryptic "SyntaxError: multiple exception types must be parenthesized" message means.
All it's trying to tell you is that in the newer version of Python you're using, this syntax is no longer valid:
except COMError, err:
instead, you should be using this syntax:
except COMError(err):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With