Debugging Bash, using VSCode
Stephen Warren
swarren at wwwdotorg.org
Sat Jan 22 14:41:55 MST 2022
On 1/22/22 14:06, Brian Sturgill wrote:
> sudo apt install python-is-python3
That may be dangerous; it changes the default "python" to be "python3".
If any scripts that use "#!/usr/bin/env python" are actually Python 2
scripts, there's a good chance they won't work right. Presumably you
suggested this because part of vscode's Bash debugger is implemented in
Python and needs Python 3? If so, is there a way to configure vscode to
use a specific Python binary, e.g. /usr/bin/python3? That approach would
have fewer system-level implications.
As an aside, this is why when writing Python you should write:
#!/usr/bin/env python3
or just maybe for ancient code:
#!/usr/bin/env python2
not:
#!/usr/bin/env python
That way, your script is immune to this kind of issue, since it
explicitly calls out the major version of Python that it needs.
More information about the NCLUG
mailing list