Windows 10 + Python = VS Code + WSL
Tags: wsl, linux, python, windows
Published: 2019-12-11 01:54:46

![Microsoft](http://www.queworx.com/wp-content/uploads/2019/12/m2_ceykmjmgcdvt9mn0_6vok2r8.png)


*[Translation of an article originally posted on [habr.ru](https://habr.com/en/post/472202/), published by [r_clark](https://habr.com/en/users/r_clark/)
on October 20, 2019]*

**Microsoft**… The technological locomotive of our time. It’s no secret that they’re cool, and that they’re absorbing more and more… ~~of everything~~. Fortunately, lately they have only been encouraging me with their potential. And after the [presentation](https://www.theverge.com/2019/10/3/20896908/microsoft-windows-satya-nadella-importance-apps-services-android) by *Satya Nadella*, where he told the world that Windows is no longer the main product of the company, as they set their course on the implementation of their APIs… ~~Everywhere~~…

They aren’t skimping for software developers either. C#, Azure, Visual Studio… But right now we’ll talk about Python, since they warmed up a spot for it as well.

##Briefly about WSL

With a Windows update it became possibly to use [WSL](https://docs.microsoft.com/ru-ru/windows/wsl/about) (Windows Subsystem for Linux). Not too long ago [WSL2](https://docs.microsoft.com/ru-ru/windows/wsl/wsl2-about) appeared with VERY cool improvements. WSL2 uses the latest and newest virtualization technology to launch a Linux kernel inside a simplified service virtual machine. That means that attributes like isolation and slow downs are now absent.

##Linux or Linux

Sooner or later, developers decide on what environment to develop in, and that is a very important moment. A fairly important role is played by the operating system, where the code is run. Since the issue is not just about the compiler and interpreter, but also the services that work in a close and friendly circle. And the OS answers for the correctness of the work of these fighting units. The conversation is going to be Windows and Linux. And it’s not going to be about IT’S better, or IT’S worse, since the choice of editor or system is no more than a matter of taste these days. ALL of them these days provide a mass of tools for implementing something. The reason that I prefer Linux is flexibility. Unfortunately, not all additions to Python work on the brainchild of Microsoft. For example, celery/redis, git, work with local web servers, docker…. I think those who worked with at least those technologies met with “some difficulties”. So I think that for any Python programmer, working with Linux (MacOS) is necessary, to put it mildly…

##Beginning of Work

And so, you set a flag in Windows components

![Windows subsystem for linux](http://www.queworx.com/wp-content/uploads/2019/12/yul909wkrw-8aex1vw4wcf7smxq.png)

and downloaded your favorite distribution from the official store.

![Ubuntu image](http://www.queworx.com/wp-content/uploads/2019/12/ykzuddsdwxi0eepyuycn1alsmke-1024x326.png)

After some simple user creation manipulations, you get access to the Linux terminal. Nothing unusual, if you don’t take into account, that the file system of both operating systems isn’t isolated from one another, making it possible to manipulate the Windows file system from inside Linux. All logical partitions are available at the mount point.

```/mnt/c/Program Files/```

##Development

Now we proceed directly to the development. When choosing an editor, I would stay with **Visual Studio Code**. It includes a lot of tools, including a debugger, which makes it a full-fledged IDE. The creation of a virtual environment on different systems is different. For example, after a applying the command

```python -m venv venv```

on windows it creates a .bat activator and a python.exe file, while Linux copies the Python binary system. VS Code is fairly flexibly set up with the help of extensions.

``` Ctrl+Shift+X ```

allows you to quickly jump to add-ons. It necessary to enter WSL into search and download the first extension from the list.

![Remote WSL](http://www.queworx.com/wp-content/uploads/2019/12/tsre1mb4j37fhgod5lf0eqaxvgu-1024x271.png)

For convenient development it’s worth adding Python, Git History, Django… And then whatever your heart desires.

![Python](http://www.queworx.com/wp-content/uploads/2019/12/xvg7phvowlbcdrz2nqu_zjixmsq-1024x213.png)

![Python Preview](http://www.queworx.com/wp-content/uploads/2019/12/wvu6l-iztklhv_bstg_fumqqdjy.png)

![Git History](http://www.queworx.com/wp-content/uploads/2019/12/sd4i-n4pt1iky9a12nrksqjrnuu.png)

**After that**, boldly restart the editor, after which you can open your project

```File -> Open Folder```

After loading, pay attention to the lower left corner of the screen.

![lower corner WSL](http://www.queworx.com/wp-content/uploads/2019/12/7eev4rxa14extkiasc5w3tkegqc.png)

This will allow you to re-open the folder using WSL

![Reopen folder in WSL](http://www.queworx.com/wp-content/uploads/2019/12/w5bq95tlxi5r86m5fhzg978ln3w.png)

*The difference being*, that VS Code in this case switches to the Linux kernel, which happens to be the bottom layer of the Windows kernel. This will allow you to use the desired interpreter, as well as the terminal directly from the editor.

![Select Interpreter](http://www.queworx.com/wp-content/uploads/2019/12/zggiiyiwd36jvqsov6zlc2ziggk.png)

![Select Python](http://www.queworx.com/wp-content/uploads/2019/12/hcuon9e78wapx0yfk5a2-si3dvc.png)

In the same way, it’s possible to use the Windows Terminal. This will greatly increase the effectiveness of your work, since WSL is also integrated into it.

![Windows Terminal](http://www.queworx.com/wp-content/uploads/2019/12/6y_h5objrotduxx-owp6vjatimi-1024x278.png)

![cmd](http://www.queworx.com/wp-content/uploads/2019/12/h9pfkgdjayed2sjyb2csb4cmvdk-1024x117.png)

All in all, this ensures comfortable work in Windows with the capabilities of Linux. And also the predominant factor being that, the work environment has access to the main system, but is isolated from it by the kernel and the base file system.

*Other Articles*

- [Redux – Not needed! Replacing with useContext and useReducer in React?](http://www.queworx.com/2019/12/13/redux-not-needed-replacing-with-usecontext-and-usereducer-in-react/)
- [React-admin and Django Rest Framework](http://www.queworx.com/2019/12/08/react-admin-and-django-rest-framework/)