Python with VS Code

Python with VS Code

We will learn how to program Python *.py in VS Code.

We want to make sure VSCode recognizes the Anaconda installation so it can access installed packages for autocomplete, syntax highlighting, and error checking.

Prerequisite

1. Install Python Extension

  • Open VS Code

  • Press Extension Icon or Press < Ctrl +Shift +X>

  • Install Python (Microsoft)

image

2. Programming Python in VSCode

Open Working Folder in VS Code

Create a new test folder

  • Example: \Tutorial_pythonOpenCV

Open the folder in VS Code

image

Select Interpreter

Let's select the virtual environment for this tutorial.

Press F1 > 'Python: Select Interpreter' > Choose py37 as the Interpreter

image

Run Test Code

(1) Create a new file

(2) Name the file as TU_pytest.py

(3) Program the code

import numpy as np
a = np.array([1,2,3])
print(a*a)

(4) Run Python File

(5) It should give the output as

[1 4 9]

image

Further Reading

How to program Jupyter and CoLab(Notebook) in VS Code

Last updated

Was this helpful?