How to run Python code under TypeScript

How to run Python code under TypeScript: a blog demonstrating how to run Python code from vscode in different ways.



The project has been updated and is now called “Python with VSCode”. The main features are:

– You can run your code in different shells, if you want to test some things on the go (i.e. without having to install anything)

– You can write Python scripts as “scripts” and run them directly from the editor (without using vscode). This means you can use Python as a scripting language that works on any platform – Windows, Mac OSX or Linux – without having any knowledge of the command line or programming in general.

It also provides support for the following languages:

– JavaScript (via nodejs)

– PHP (via PHPStorm)

– Ruby (via rbenv)

– C

vscode is a very popular IDE for many programming languages, including Python. It offers rich integration with TypeScript, and in this blog we demonstrate how to run Python code under TypeScript in vscode.

First of all, you need to install the Python extension for vscode by Don Jayamanne. You can find it in the extension panel of vscode:


Once installed, you can create a new .py file and run the code by clicking on the “Run Code” button in the text editor:


You can also run your code by right-clicking in the text editor and selecting “Run Python File in Terminal.”

This is an open-source blog written in TypeScript, and the goal of this blog is to demonstrate how we can run Python code from vscode. If you want to find more information about the project, please visit my GitHub repo here.

For this blog, I am using Visual Studio Code as my IDE. If you don’t have it installed, please go to and download the latest version.

Running Python in TypeScript:

To run Python code in vscode, we need some extra packages (extensions). We will use two extensions:

1 – Code Runner:

This extension helps us run any language’s code snippets right inside our editor without needing a terminal or any external program. You can download it by clicking on the link or by going to your vscode and searching for “Code Runner” and installing it from there.

2 – Python:

This extension adds rich support for the Python programming language to VS Code. This includes features such as IntelliSense, linting, debugging, code navigation, code formatting, Jupyter notebook support, refactoring, variable explorer, test explorer, snippets and more! You can download it by clicking on the link

This is just a quick blog demonstrating how to run Python code directly from vscode.

I am using VSCode 1.18.1 and Python 2.7 on Mac OSX 10.12.6, but this should work on any platform (Windows, Linux) with the latest vscode and python installed.

Running Code

There are two ways to run Python code in vscode:

1) Selecting Run Python File in Terminal in the Command Palette (Ctrl+Shift+P). This does not require any special configuration, just open a .py file and press the above shortcut!

2) Adding a task to your tasks.json file

The second method is more useful when you need to do more advanced things, like running a script that uses other libraries or running a script with arguments. In order to add a task you will need to open your tasks.json file by pressing Ctrl+Shift+B and selecting Configure Task Runner from the drop down menu, which will create a tasks.json file in your .vscode folder if it doesn’t already exist. Here is an example of what you can put into your tasks.json file:


“version”: “0.1.0

There are many ways to run Python code from vscode. This blog will introduce some commonly used methods.

1. Run the script in python terminal.

The first is to install the extension Python, then open the command palette and select the option Run Python File in Terminal, or use the shortcut Ctrl + Shift + P (Cmd on macOS) and type “Python”.

2. Run the script in jupyter notebook.

The second is to install vscode-jupyter, then open vscode-jupyter and select Create New Jupyter Notebook, which opens a new browser window and runs jupyter notebook there. In that browser window, you can create a new notebook file with python kernel or run any existing ipynb file. By default, it runs under http://localhost:8888/, which means you don’t need to start jupyter notebook manually before running it. If you want to change this port number, you can add it in your user settings: “vscode-jupyter.serverURI”: “http://localhost:8889/”.

3. Run the script in jupyter console.

The third method is similar to the

The code can be executed in three different ways:

With the Node.js runtime environment.

In a browser (as a WebAssembly module).

In a Python interpreter.

This blog describes how to do each of these.

The purpose of this blog is to provide a step-by-step guide for setting up a Python development environment using TypeScript, in your browser.

The process I will outline here is not the only way to do it, but it is the best way if you are going to use TypeScript.

The first step in setting up a Python development environment is to install TypeScript. There are many ways to do this, but the easiest and most reliable method is to go to the official website.

The second step is to download the free TypeScript compiler. You can find this on the right side of the page under “Downloads.” You will need this file later in your setup.

The third step is to download the free Visual Studio Code. This code editor is available for Windows, Mac, and Linux and has been around since 1998.

You will also need access to a text editor like Notepad++ or Sublime Text 2.*

Leave a Reply

Your email address will not be published. Required fields are marked *