1. Install Python
Install Python extension.
Install a python3 version.
2. Connect to Python
Select a python interpreter
If you want to run python code in vscode, you must tell vscode which interpreter to use.
You can open the command palette (Ctrl Shift P) and type Python: Select Interpreter and then select an interpreter. You can also directly click Select Python Environment in the picture above to make a selection.
This command displays a list of available interpreters that vscode can automatically find. If you do not see the required interpreter, click File>Preferences>Settings and set the value of python.pythonPath to select yours. The interpreter you want to use.
Run the file
The easiest way is to right-click and select Run in Terminal.
There are two other ways to run python in vscode:
Select a line and press shift enter to run this line of code directly.
Use the Python: Start REPL command in the command panel to open the python interpreter.
Recommended learning: vscode tutorial
The above is the detailed content of How to connect vscode to python. For more information, please follow other related articles on the PHP Chinese website!