I have this problem: Unable to run 'keyboard.is_pressed' on Mac
To fix this, I need to run it as an administrator from the terminal. Is there a way to do this from Visual Studio Code? Thanks
I have now also tried so other things that have been, so far, unsuccessful. These are:
- Launching VS Code as an admin
- changing my launch.json with "sudo": true and some other things the internet said to do
- running the python file as an administrator to see if that gives it the correct "privileges" to be run as admin from the app
- given VS Code access to my documents folder
the requested message, final few lines:
Library/Frameworks/Python.framework/Versions/3.9/bin/python3' '/Users/wayow/.vscode/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/launcher' '59853' '--' '/Users/wayow/mystuff/Pythonstuff/test/problemthing.py'
env: illegal option -- a
usage: env [-iv] [-P utilpath] [-S string] [-u name]
[name=value ...] [utility [argument ...]]
CodePudding user response:
Try to put this in .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current file",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal",
"sudo": true
}
]
}
and run your .py file and paste any error messages in your question.
It should open an external terminal.
I tested fine in MacOS Monterey.
Update
To get around env '-a'
issue, open a Terminal
and run :
mkdir $HOME/bin
Paste following (from
cat ...
includingEOF
) in theTerminal
, typeEnter
at the end :
cat <<'EOF' > $HOME/bin/env
#!/bin/bash
test "$1" = -a && shift
exec /usr/bin/env "$@"
EOF
chmod x "$HOME/bin/env"
PATH="$HOME/bin:$PATH"
open -a "Visual Studio Code" "python-project-directory"
Run .py file