Create a Python execution environment for Windows with VScode + Remote WSL

In this article, I will explain how to create a Python execution environment that runs on Windows using VScode and WSL.

merit

Before getting into the concrete construction method, I would like to explain the merits of choosing this among many Python execution environments.

  1. Advanced functions such as step execution can be used on VS Code
  2. Easy management of installed packages
  3. You can select and use the required functions.

First of all, by using VS Code for 1, the function to automatically adjust the appearance of the program such as step execution (execution while checking the behavior line by line) and auto format (spacing etc.) without making any special settings. ) Can be used. Next, regarding 2. This environment uses the virtual environment features that Python comes with by default. Therefore, you can manage packages on a command basis with pip. Also, by using it from VS Code, it is possible to easily switch between active virtual environments. Finally, regarding the third point. In the environment to be built this time, only the extensions Remote-WSL and Python are installed for VS Code, and Python is installed for WSL. You can choose and do everything from minimal construction to construction full of useful features using VS Code extensions.

Construction procedure

Now let's check the actual construction procedure. Since many articles already exist, I will omit the installation of VS Code and WSL.

WSL side setup

Python installation. Please enter a version specification if you like.

Create a project directory and create a virtual environment folder under it.

cd sample_project
python3 -m venv venv

VS Code side setup

Please install the extension "Remote-WSL". image.png After that, open Remote-WSL once (lower left, green icon), and install the extension "Python" on the Remote-WSL side. (Extensions are managed separately on the Windows side and Remote-WSL side. Additional settings are required even if the Python extension is already installed)

How to execute code

Open the sample_project folder created on WSL from VS Code using the Remote-WSL function (from the menu File-> Open Folder). In this state, VS Code recognizes the virtual environment placed in the folder and automatically reads it. You can execute the code with the virtual environment in the folder activated by opening the .py file you want to execute and pressing the F5 key. You can also set breakpoints.

Recommended Posts

Create a Python execution environment for Windows with VScode + Remote WSL
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Create a virtual environment with Python!
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
Create a simple Python development environment with VSCode & Docker Desktop
Let's create a virtual environment for Python
[Python] Create a virtual environment with Anaconda
Building a Python 3.6 environment with Windows + PowerShell
Create a Python environment for professionals in VS Code on Windows
Building a Windows 7 environment for getting started with machine learning with Python
Try to create a python environment with Visual Studio Code & WSL
Create a USB boot Ubuntu with a Python environment for data analysis
Create a Python environment
Create execution environment for each language with boot2docker
Simply build a Python 3 execution environment on Windows
Create a LINE BOT with Minette for Python
Create a virtual environment with conda in Python
Create a python3 build environment with Sublime Text3
Image Processing with Python Environment Setup for Windows
Commands for creating a python3 environment with virtualenv
Create a Python execution environment on IBM i
Create a Python virtual development environment on Windows
Build a python execution environment with VS Code
Steps to create a Python virtual environment with VS Code on Windows
Build a python environment for each directory with pyenv-virtualenv
Use Python installed with pyenv for PL / Python execution environment
Create a comfortable Python 3 (Anaconda) development environment on windows
Create a python development environment with vagrant + ansible + fabric
Procedure for building a CDK environment on Windows (Python)
Create a Layer for AWS Lambda Python with Docker
Create a directory with python
Create a decent shell and python environment on Windows
Create an exe file that works in a Windows environment without Python with PyInstaller
Until you create a machine learning environment with Python on Windows 7 and run it
Create a child account for connect with Stripe in Python
Create a Twitter BOT with the GoogleAppEngine SDK for Python
Build a comfortable development environment with VSCode x Remote Development x Pipenv
Create a virtual environment for python on mac [Very easy]
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
[Python] Create a screen for HTTP status code 403/404/500 with Django
Create a Python environment on Mac (2017/4)
Building a virtual environment with Python 3
Create a Linux environment on Windows 10
Create a python environment on centos
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
Example of building python development environment on windows (wsl2, vscode, pipenv)
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Create a striped illusion with gamma correction for Python3 and openCV3
Create a color picker for the color wheel with Python + Qt (PySide)
Create a development environment for Go + MySQL + nginx with Docker (docker-compose)
Build a Python execution environment using GPU with GCP Compute engine
[Mac] Create a Python3 execution environment from the fully initialized state
Create a simple Python development environment with VS Code and Docker
LaTeX and R (a little Python) environment construction with SublimeText3 (Windows)
[Pyenv] Building a python environment with ubuntu 16.04
Create a Python function decorator with Class
Building a Python3 environment with Amazon Linux2
Python project environment construction procedure (for windows)
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.