VS Code
Python Extension
VS Code is a multi-purpose code editor. To execute Python scripts we need to install the Python extension from the VS Code Marketplace.
Click the extensions icon in the activity bar on the left side of the editor and search the extension name in the search box. Once found, select it and click Install.
Recommended Extensions
Although not strictly necessary, we also recommend the following additional extensions.
Pylance
File Utils
Anaconda Extension Pack
EditorConfig
The Command Palette
The Command Palette provides access to all VS Code commands. Top open the Command Palette, select it from the View menu (View > Command Palette
), or use the keyboard shortcut.
Windows:
Shift+Ctrl+P
macOS:
Shift+Cmd+P
Commands are grouped into categories. To list only the commands of a particular category, simply type the name of the category at the Command Pallete prompt (>
). For example to list all Python commands, type Python
Select a Python Interpreter
Open the Command Palette.
Select
Python: Select Interpreter
Select
Python x.x.x ('ita21':conda)
from the listed environments.
Select a Python Linter
Open the Command Palette.
Select
Python: Select Linter
Select
flake8
.
Select the Default Terminal Profile
This is for Windows users.
Open the Command Palette.
Select
Terminal: Select Default Profile
Select
Command Prompt
Don't use the PowerShell since this will create all sorts of problems! Note that this change will only have an effect after all current terminals are shut down.
Create a new Python file
Use keyboard shortcut: Shift+Ctrl+N
for Windows, or Shift+Cmd+N
for Mac to create a file. Save it as test.py
.
Note that when you create a new file, the default file format is .txt
. So, if you want to write a Python code, make sure to specify the format .py
.
First Python script in VS Code
Type the following code in the text editor. Make sure that you have saved the file as .py
.
Right click the text editor and then select Run Python File in Terminal
in the context menu. You should be able to see the print results 1.8.1
in the Terminal menu. Hooray! It means that we have installed compas correctly.
Plotter
Copy the following code in your text editor and run the file. You will see a pop-up window similar to the picture below.
Last updated