pip
with get-pip.py
.brew install python3
(the system install of Python on macOS is not supported).Note You can use thepy -0
command in the integrated terminal to view the versions of python installed on your machine. The default interpreter is identified by an asterisk (*).
code
) in that folder (.
) by entering the following commands:.vscode/settings.json
, which are separate from user settings that are stored globally.('base':conda)
, for example Python 3.7.3 64-bit ('base':conda)
.python.pythonPath
value in your workspace settings to the path of the interpreter. To see the setting, select File > Preferences > Settings (Code > Preferences > Settings on macOS), then select the Workspace Settings tab.python.pythonPath
in your user settings instead, which sets the default interpreter for VS Code in general. The user setting makes sure you always have a default interpreter for Python projects. The workspace settings lets you override the user setting.hello
folder:hello.py
, and it automatically opens in the editor:.py
file extension, you tell VS Code to interpret this file as a Python program, so that it evaluates the contents with the Python extension and the selected interpreter.print
, notice how IntelliSense presents auto-completion options.msg
variable contains a string, IntelliSense provides string methods when you type msg.
:msg
variable and the print
call, and save the file (⌘S (Windows, Linux Ctrl+S)).hello.py
with Python. Right-click anywhere in the editor window and select Run Python File in Terminal (which saves the file automatically):python3 hello.py
(macOS/Linux) or python hello.py
(Windows):hello.py
by placing the cursor on the print
call and pressing F9. Alternately, just click in the editor's left gutter, next to the line numbers. When you set a breakpoint, a red circle appears in the gutter.launch.json
is the standard name for a file containing debugging configurations.launch.json
file within a .vscode
folder (located in the folder's root directory) that contains a pre-defined configuration based on your selection (you can also learn more about this file in Debugging configurations).msg
variable appears in the Local pane.msg
, hovering over the variable will display the string Hello world
in a box above the variable.stopOnEntry
is set to true, in which case the debugger stops before any code is run.)print
statements to quickly inspect variables without necessarily stepping through each line of code in a debugger. In VS Code, you can instead use Logpoints. A Logpoint is like a breakpoint except that it logs a message to the console and doesn't stop the program. For more information, see Logpoints in the main VS Code debugging article.launch.json
for you, create the .vscode/launch.json
file within the project folder (creating the .vscode
folder if you need to), then paste the following contents into launch.json
:launch.json
was showing in the editor. The error occurs because launch.json
is not Python code like hello.py
:hello.py
and try again. Alternately, create a debug configuration specifically for the hello.py
file by adding the following lines in launch.json
within the configuration
array. Then select this configuration in the debugger drop-down and start the debugger again.pythonPath: ${workspaceFolder}
in your launch.json
file, but your Python interpreter actually exists in a different path. Check the value, or remove the pythonPath
property altogether.matplotlib
and numpy
packages to create a graphical plot as is commonly done with data science. (Note that matplotlib
cannot show graphs when running in the Windows Subsystem for Linux as it lacks the necessary UI support.)standardplot.py
, and paste in the following source code:as
keywords when you press Enter at the end of a line. To avoid this, type a space, then Enter.'stopOnEntry': true
in that configuration, you need to select the run command again to continue.)matplotlib
package, you should see the message, 'ModuleNotFoundError: No module named 'matplotlib'. Such a message indicates that the required package isn't available in your system.matplotlib
package (which also installs numpy
as a dependency), stop the debugger and use the Command Palette to run Terminal: Create New Integrated Terminal (⌃⇧` (Windows, Linux Ctrl+Shift+`))). This command opens a command prompt for your selected interpreter.virtual environment
that contains a copy of a global interpreter. Once you activate that environment, any packages you then install are isolated from other environments. Such isolation reduces many complications that can arise from conflicting package versions. To create a virtual environment
and install the required packages, enter the following commands as appropriate for your operating system:deactivate
in the terminal window to deactivate the virtual environment.