Mac OS Mojave microphone permission for Visual Studio Code - python

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
p.s: 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.

Related

MacOS: "PermissionError: [Errno 1] Operation not permitted" when trying to import modules in Spyder [duplicate]

After upgrading macOS to Catalina, my Anaconda installation was helpfully reconfigured by Apple. Advice from the Anaconda website suggested a fresh install was the best way to go. Did that and all seemed good. I use spyder from the Anaconda navigator. But trying a previously running python code failed due to apparent file permission problems. For example,
file='/Users/stingay/Documents/Coaching/WAIS/2019:20/041019/Race Walk Test-2019-10-04T16.29.13.774-C5612E80FB1D-Accelerometer.csv'
with open(file,'rt') as f:
data = csv.reader(f)
next(data)
results in:
PermissionError: [Errno 1] Operation not permitted: '/Users/stingay/Documents/Coaching/WAIS/2019:20/041019/Race Walk Test-2019-10-04T16.29.13.774-C5612E80FB1D-Accelerometer.csv'
I can't see an issue with the permissions on the file or the directory structure in which the file sits. If I move the file to~/.spyder-py3 (the working directory), it works.
Looks like there is some extra python/spyder/anaconda permissions issue with the file/directory I can't spot. Any ideas?
I guess you have solved this by now, but for future reference, I still post my answer.
TLDR: I opened a file (from the folder causing the problem) directly in
the spyder editor (File | open). As a consequence, the editor should have triggered the pop-up dialog question whether you want to allow access or not. In my case, the mac silently granted python/spyder access to the folder. Now I can run the code in spyder without more problems than I have caused myself.
Longer version:
The source of your problem is described here:
https://www.howtogeek.com/443611/how-macos-catalinas-new-security-features-work/
Knowing that links are something frown upon, here's a summary:
The problem is that the folders "Documents" and "Downloads" folders nowadays are protected and you would need to go to the security & privacy settings and "Files and Folder,s" and allow the applications to access these. Unfortunately, spyder does not show up here. So, if you want to run your python program from the terminal, you should probably grant the terminal access to the folders.
Total noob here, but I might have stumbled upon a solution for people that have problems reading in their data in spyder after the Catalina update. I had the same problems you describe and got the same file permission errors.
I couldn't resolve the issue, reinstalled several times but didn't work for me. I couldn't use my Utorrent either, and while attempting to solve that problem I came across https://discuss.pixls.us/t/problems-with-darktable-and-mac-osx-catalina-solved-with-dt-2-6-3-1/14400/19 this forum.
Long story short, in the forum people couldn't really resolve the issue, but someone pointed out that if you just run the application from the terminal, it somehow works. I tried to do this with Spyder, and I seem to be able to use the read_csv('file') function again. So try opening the terminal, then type 'spyder' (without '') and press enter. Somehow all issues seem to be resolved. Hope this helps someone.
Same problem here. I re-installed Anaconda based on this link and Python is able to access folders where Catalina has added newly restricted security:
Install Anaconda following instructions below:
https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/
For Anaconda-Jupyter user, you are good to go
For Commandline (Terminal) Python user, you are good to go
For Anaconda-Spyder user, two options as a workaround after installation above:
Avoid Mac default setup-folders and relocate files to /Users/[user_name]/..
OR
Launch Spyder through Terminal (execute "sudo spyder") under root user
Lastly, changing or reseting folder/file permission does not resolve permission issue. Despite of the security issue under the more restricted security folders, somehow Spyder-Python is able to open .py files in these folders.
Since Jupyter and commandline Python can access these folders, I assume there will be a fix in the future for Anaconda-Spyder.
My code didn't work at all after Catalina update. The simplest partial solution that I found was to copy all files containing the scripts in a new folder. That works at least to run the codes, but I still dealing with annoying message to allow access to my files.
conda update --all in terminal worked for me. It updated everything. I did have to go through the annoying messages for access to my files as well. but after clicking yes a hundred times it was ab

Basepath argument is not fully qualified. Parameter name: basePath. I can not use code completion

I just open a .py file on visual-studio-code. And I got a message:Basepath argument is not fully qualified.
Parameter name: basePath. And I can not use python completion. The source of this message is Python(Extension) of Microsoft.
Here is image description
I had the same issue today, and I opened a folder in VSCode(The path of you .py file. You can see the option in your image). It seems that it works for me now. I'm not sure whether it will be helpful to you.
Same thing happened to me, it started today.
I checked my Python install, python path in sys, reinstalled VSCode and no changes.
Im using Python 3.7, win 10.
In the end what solved it for me was in settings.json, in VSCode, set "python.jediEnabled": true and after that VSCode prompted me with a warning that one of the extensions uses the language server (sorry i forgot the name of the extension, it was an old python autocomplete extension), after removing that extension everything was working fine.
As far as i understand it was a problem with the ms language server, jediEnabled setting configures the VSCode to use Jedi as the IntelliSense engine instead of Microsoft Python Language Server, some extensions require ms lang server so if you remove them you should be good.
Give it a try, hope it helps.
I had the same issue yesterday and solved it this afternoon.
The source of this message is also Python(Extension) of Microsoft.
But, and i assume this is maybe the same for you, it was linked to "IntelliCode extension for VS Code (preview)" which asked me to activate pylit.
So the only way i found to repair the software was to delete my preferences files to reset Visual Studio Code and boot like the first time.
Then i re-installed my extensions and preferences.
You do not need to uninstall the soft.
Note that uninstalling Visual Studio Code won't change anything if you don't delete manually the preferences files.
Here how to do it on Windows :
https://filljoyner.com/2018/08/18/how-to-reset-visual-studio-code-on-windows/

Python setup failed error 0x80070005 access denied

When installing python on my system I am getting this error shown in below picture.
Please help how can I fix this issue?
My account has admin rights on windows 10 pro 64 bit operating system.
I have downloaded python setup from below link:
https://www.python.org/downloads/windows/
This error manifests when installing Python as a Windows Store app, too. 🤦‍♂️
Open 'Manage App Execution Aliases' through Start and disable all the Python entries before installing. After installation successfully completes, enable the appropriate aliases for python.exe, python3.exe and possible other version-specific ones.
The fix for this is in the review comments for Python 3.8 on the
Microsoft Store. A review comment by someone named Jan on 11/29/2019
points back to a post from 11/19/2019 where Python Software Foundation
replied with a fix for another error and that fix also fixes this
0x80070005 error.
That fix is: "...open 'Manage App Execution Aliases' through Start and
disable all the Python entries before installing."
I just did this and it worked for me. I could successfully install.
-- https://answers.microsoft.com/en-us/windows/forum/all/error-code-0x80070005-with-microsoft-store/2377a155-8915-4674-b41f-feddd104e0bd
i assume you have admin access or you starting this installation as "Run as
Administrator"
Following are the steps that you need to try now :
1) Turn off the firewall and the anti-virus, and use the admin rights to run
2) otherwise, you have modify your BIOS options on windows to reset the permissions
3) Run this , and it will help you to identify any malwares if any
4) And final option would be like,
reset win 7 (you can keep ur file but will reinstall software)
after reset, do the windows update (otherwise you`ll get a 0*80070652 error)
reinstall again! this will work for sure.
This usually happens due to Package Cache Folder absent in your local data.
Check the python log (from your installation window; where you see the error), scroll down to the end. After Restore Point Creation point log, you would find that it is unable to transfer file from local temp cache to this location C:\Users<>\AppData\local\Package Cache.
To isolate this, check if the path exists in your system or not? If not then please create the folder name Package Cache in local folder.
Once you do, you would notice that fodler is populated with some temporary downloads.
Reinstall the python package. This time it will install.
I had the same issue in my organization where I was using VDI. The folder was not present there and thats why everytime it comes to that point, it was failing.
I was able to fix the issue.
Perhaps try running with explicit admin rights.
Right click on executable -> Run as administrator.
Although the description for the error code you mentioned is here:
https://answers.microsoft.com/en-us/windows/forum/all/windows-update-error-0x80070005-need-a-fix-click/e4cb8700-f215-4f1a-8bd4-6457ac619c19
Apparently I had this same issue on my Windows 7 Machine.
The solution for me was to go to C:\User\"Username"\AppData and then Rightclick > properties on the "Local" folder and and "allow permissions" for everyone.
Strict Windows firewall settings will still cause the 0x80070005 error even with automatic updates. In my case that was the issue and the source of error. I had to disable the firewall. Opening the firewall settings revealed that my antivirus was controlling my firewall settings. In this case you would need to open your antivirus and disable the firewall from there.
Here's a link that helped me figure this out. Skip all the steps (they didn't work for me) before the part about disabling the firewall.
Hope this helps!
The log from the installation shows that it tries to use a directory in the home directory (namely: C:\Users\<uname>\AppData\Local\Package Cache\; if not present create the folder) which the installer has somehow no permission for.
Allowing everyone (note: probably something less permissive would be a good idea) to access this folder does the trick:

"pythonw.exe has stopped working" crashing error after launching anaconda

After launching anaconda, python crashes with message "pythonw.exe has stopped working".
Please find error screenshot here
I had downloaded some packages(nltk). And after that my anaconda stopped working.
It is giving me Navigator Error :
An Unexpected error occurred on Navigator startup
psutil.AccessDenied(pid=3232)
Tried reinstalling the anaconda,
Also reboot the system,
Fired 'conda update anaconda-navigator' command.
But does not worked.
Access Denied errors usually mean a process is trying to open a file that's already open, or the program doesn't have sufficient permission from Windows to read the particular file.
In this case, it looks like the anaconda-navigator package is having trouble. Look at the python scripts mentioned in the error trace (start.py, line 108 and misc.py, line 348) and try to find out what file it is trying to open. Then, go to that file in Windows Explorer and give whatever user pythonw.exe is running under (probably your user account, or possibly the Administrators group) permission to read that file. Depending on what navigator's trying to do, it might need write permissions as well. See here for more info on Windows File permissions.

Errors while attempting to install Python 2.7.13 and 3.5.2 on Windows

I have been trying to install either Python 2.7.13 and 3.5.2 on Windows 64-bits. I continue to get the following error:
Error writing file: C:\Python27\tcl\tcl8.5\encoding\ascii.enc.
Verify that you have access to that directory.
I have tried EVERYTHING suggested on Google search outcomes, including trying to install it in a drive other than C, running chkdsk at boot time,and many other suggestions. I verify that I have full access to the directory. I also tried the installation as Administrator. Nothing works for me.
Can someone help?
Thank you.
Try going to your c drive and checking the security settings. Make sure you have full rights to it. Then go to your accounts in control panel and make sure you are an admin.
You can also go into the directory and try to save a txt document to see if you have permissions.

Categories

Resources