简体   繁体   中英

Mac OS Mojave microphone permission for Visual Studio Code

I'm trying record audio with PyAudio however when working in VSCode no microphone permission request is generated.

I have done an NVRAM reset which allowed me to run the script though the terminal (after it generated a permission request).

Within the privacy settings the only apps available are Chrome and Terminal, so it is not possible to give VSCode permission here.

Is there a way to force a permission request for VSCode? Or somehow otherwise edit the microphone permissions?

VScode may have a bug in that it doesn't seem to request permissions when needed. I'm facing a similar problem when trying to create an Excel spreadsheet using xlwings (OS is Catalina). I found a related github ticket #95062 saying VScode doesn't ask for permissions to access media devices.

I can bypass the need for requesting permissions by launching VScode with admin permissions from terminal sudo /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron . I can also run my xlwings code from terminal with normal permissions because terminal requested the needed permissions when expected. PyCharm also asked for permission when used to run the same xlwings code, which reinforces my belief that it's a permissions request bug in VSCode.

Completely true answer above. The main issue is that the Python referenced in the visual code is piped through the visual code. So as the main app hasn't the right permissions for the microphone, the python also will not have it. (Have a look at Heritage of permissions in Unix). So a good solution is:

1. Start the script over the Terminal python ./script.py 
(The microphone will ask the permission)
2. Close visual code
3. Open a terminal
4. put: sudo /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron
5. Should work!

Cheers

ps: if I find a way to fix it directly I will let you know!

Actually after I add Terminal to the list of Microphone access from macOS Privacy setting, The VS Code works fine. And VS Code is good for security settings~ It's prompt me don't open it user 'root' account.

1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM