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?
After a time searching I found that comtypes uses a tool to be compatible with both python 2 and 3 and that is no longer works in new versions. I had to downgrade two packages and reinstall comtypes:
pip install setuptools==57.0.0 --force-reinstall
pip install wheel==0.36.2 --force-reinstall
pip uninstall comtypes
pip install --no-cache-dir comtypes