To resolve the issue of Visual Studio Code defaulting to "python2.7" instead of the desired version, you can follow these steps:
Open Visual Studio Code and go to the workspace or folder where your Python files are located.
Check the user settings by navigating to File -> Preferences -> Settings. Search for "python.pythonPath" and verify that it is set to the desired Python version, such as "python3". If it is not set correctly, update the value accordingly.
Access the workspace settings by clicking on the settings icon in the left sidebar and selecting "Workspace Settings". Ensure that the "python.pythonPath" value in the workspace settings points to the desired Python version installed in the specific workspace folder, for example, "${workspaceFolder}/env/bin/python3.6".
Review the configuration in the tasks.json file. Confirm that the "command" is set to "python3" and that the "args" include "${file}" to pass the current file as an argument.
Save the configuration changes and restart Visual Studio Code to apply the updated settings.
Attempt to use the debug console or execute your Python code again. This time, Visual Studio Code should utilize the desired Python version specified in the configuration.
By following these steps, you should be able to rectify the issue and ensure that Visual Studio Code uses the correct Python version.