{"id":4877,"date":"2019-07-22T16:29:47","date_gmt":"2019-07-22T23:29:47","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/commandline\/?p=4877"},"modified":"2019-08-14T15:41:46","modified_gmt":"2019-08-14T22:41:46","slug":"an-in-depth-tutorial-on-linux-development-on-windows-with-wsl-and-visual-studio-code","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/commandline\/an-in-depth-tutorial-on-linux-development-on-windows-with-wsl-and-visual-studio-code\/","title":{"rendered":"An In Depth Tutorial on Linux Development on Windows with WSL and Visual Studio Code"},"content":{"rendered":"<p>In an earlier blog post, <a href=\"https:\/\/devblogs.microsoft.com\/commandline\/take-your-linux-development-experience-in-windows-to-the-next-level-with-wsl-and-visual-studio-code-remote\/\">Take your Linux development experience in Windows to the next level with the Windows Subsystem for Linux (WSL) and Visual Studio Code Remote<\/a>, we introduced an overview of the VS Code <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.remote-wsl\">Remote &#8211; WSL extension<\/a>, which simplifies Linux development on Windows Subsystem on Linux (WSL). Put on your SCUBA gear, because in this follow up we&#8217;ll give you a deep dive tutorial on how to setup WSL and VS Code for Python development by creating a Python &#8220;Hello World&#8221; application.<\/p>\n<h2>Windows: A great platform for building Linux Apps<\/h2>\n<p>Windows is the most popular operating system in the world, with <a href=\"https:\/\/insights.stackoverflow.com\/survey\/2019#technology-_-developers-primary-operating-systems\">almost 50% of developers<\/a> using it every day. At the same time, many of these developers are building applications that are <a href=\"https:\/\/insights.stackoverflow.com\/survey\/2019#technology-_-platforms\">deployed to Linux-based<\/a> servers running in the cloud or on-premises.<\/p>\n<p>With WSL and VS Code, you can now seamlessly develop Linux-based applications on Windows. WSL lets you run a full Linux distro on Windows, where you can install platform-specific toolchains, utilities, and runtimes.<\/p>\n<p>VS Code and the WSL extension let you develop in the context of the Linux environment, using those tools and runtimes, from the comfort of Windows. All of your VS Code settings are maintained across Windows and Linux, making it easy to switch back and forth. Commands and workspace extensions are run directly in Linux, so you don&#8217;t have to worry about pathing issues, binary compatibility, or other cross-OS challenges. You&#8217;re able to use VS Code in WSL just as you would from Windows. One tool, two operating systems.<\/p>\n<p>If it sounds magical, that&#8217;s because it is! But, don&#8217;t take our word for it. Let&#8217;s get our hands dirty and build a simple Python3 application so you can experience the magic for yourself.<\/p>\n<h2>Install and set up WSL<\/h2>\n<p>You install WSL from the Microsoft Store. You can search for &#8220;Linux&#8221; in the Microsoft store to see a sub section of distributions in the store. Choose the Linux distribution you want to install and follow the prompts. You can also search for distributions in the search bar.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-distro.png\" alt=\"Selecting a WSL distro from the start menu\" width=\"1586\" height=\"1370\" class=\"aligncenter size-full wp-image-4891\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-distro.png 1586w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-distro-300x259.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-distro-768x663.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-distro-1024x885.png 1024w\" sizes=\"(max-width: 1586px) 100vw, 1586px\" \/><\/p>\n<p>Select <strong>Install<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/install-ubuntu.png\" alt=\"Installing the Ubuntu WSL distro\" width=\"1832\" height=\"830\" class=\"aligncenter size-full wp-image-4900\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/install-ubuntu.png 1832w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/install-ubuntu-300x136.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/install-ubuntu-768x348.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/install-ubuntu-1024x464.png 1024w\" sizes=\"(max-width: 1832px) 100vw, 1832px\" \/><\/p>\n<p>And when done, select <strong>Launch<\/strong> to get started. This will open a Linux terminal and complete the installation. You&#8217;ll need to create a user ID and password since we&#8217;re setting up a full Linux instance, but once that&#8217;s done, boom! You are running Linux on Windows.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/linux-terminal.png\" alt=\"The Linux terminal in WSL\" width=\"1670\" height=\"572\" class=\"aligncenter size-full wp-image-4902\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/linux-terminal.png 1670w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/linux-terminal-300x103.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/linux-terminal-768x263.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/linux-terminal-1024x351.png 1024w\" sizes=\"(max-width: 1670px) 100vw, 1670px\" \/><\/p>\n<h2>Python development<\/h2>\n<p>If you don&#8217;t have Python already installed, run the following commands to install Python3 and pip, the package manager for Python, into your Linux installation.<\/p>\n<pre><code class=\"bash\">sudo apt update\nsudo apt install python3 python3-pip<\/code><\/pre>\n<p>And to verify, run:<\/p>\n<pre><code class=\"bash\">python3 \u2013version<\/code><\/pre>\n<p>This isn&#8217;t intended to be a Python tutorial, so we&#8217;ll do the canonical &#8220;Hello World&#8221; app. Create a new folder called &#8220;helloWorld&#8221; and then add a Python file that will print a message when run:<\/p>\n<pre><code class=\"bash\">mkdir helloWorld && cd helloWorld\necho 'print(\"hello from python running in Linux on windows!\")' &gt;&gt; hello.py\npython3 hello.py<\/code><\/pre>\n<p>Clearly, echo isn&#8217;t a great way to do development. In a remote Linux environment (this WSL distro is technically another machine without UI, that just happens to be running locally on your computer), your development tools and experiences are pretty limited. You can run <a href=\"https:\/\/stackoverflow.blog\/2017\/05\/23\/stack-overflow-helping-one-million-developers-exit-vim\/\">Vim<\/a> in the terminal to edit your file or you can edit the sources on the Windows side through the <code>\\\\wsl$<\/code> mount:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-mount.png\" alt=\"The VSCode IDE navigated to the WSL mount location\" width=\"2024\" height=\"862\" class=\"aligncenter size-full wp-image-4895\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-mount.png 2024w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-mount-300x128.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-mount-768x327.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-mount-1024x436.png 1024w\" sizes=\"(max-width: 2024px) 100vw, 2024px\" \/><\/p>\n<p>The problem with this model is that the Python runtime, pip, or any conda packages for that matter, are not installed on Windows.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/no-python-on-windows.png\" alt=\"An image showing python is not installed on Windows\" width=\"1052\" height=\"410\" class=\"aligncenter size-full wp-image-4882\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/no-python-on-windows.png 1052w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/no-python-on-windows-300x117.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/no-python-on-windows-768x299.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/no-python-on-windows-1024x399.png 1024w\" sizes=\"(max-width: 1052px) 100vw, 1052px\" \/><\/p>\n<p>Remember, Python is installed in the Linux distro, which means if we&#8217;re editing Python files on the Windows side, we can&#8217;t run or debug them unless we install the same Python development stack on Windows. And that defeats the purpose of having an isolated Linux instance set up with all our Python tools and runtimes!<\/p>\n<p>What can we do? That&#8217;s where Visual Studio Code and the Remote \u2013 WSL extension comes to the rescue.<\/p>\n<h2>Visual Studio Code<\/h2>\n<p>VS Code is a lightweight, cross platform source code editor, built on open source. It comes with built-in support for modern web development with JavaScript, TypeScript, Node.js, CSS, etc. It also has a rich ecosystem of extensions (10K+) providing support for 100s of languages and frameworks, such as Python, Go, PHP, Java, C++, and C#.<\/p>\n<p>If you don&#8217;t already have VS Code, <a href=\"https:\/\/code.visualstudio.com\">download it now<\/a>. It&#8217;s about 50 MB to download on Windows and sets up in less than a minute.<\/p>\n<p>Now we just need the magic, and that is the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.remote-wsl\">Remote \u2013 WSL extension<\/a>. Open the Extensions view in VS Code (Ctrl+Shift+X) and search for &#8220;wsl&#8221;. Choose the <strong>Remote \u2013 WSL<\/strong> extension as seen below (it should be at the top of the list) and press <strong>Install<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-extension.png\" alt=\"The remote WSL extension install page\" width=\"868\" height=\"276\" class=\"aligncenter size-full wp-image-4889\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-extension.png 868w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-extension-300x95.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-extension-768x244.png 768w\" sizes=\"(max-width: 868px) 100vw, 868px\" \/><\/p>\n<p>Once installed, head back over the WSL terminal, make sure you are in the helloWorld folder, and type in &#8220;code .&#8221; to launch VS Code (the &#8220;.&#8221; tells VS Code to open the current folder).<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/launch-code.png\" alt=\"Launching VSCode from the WSL Terminal\" width=\"906\" height=\"233\" class=\"aligncenter size-full wp-image-4901\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/launch-code.png 906w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/launch-code-300x77.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/launch-code-768x198.png 768w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/p>\n<p>The first thing you&#8217;ll see is a message about &#8220;Installing VS Code Server&#8221; (the c7d83e57\u2026 number is the version of the VS Code Server that matches the client-side tools you just installed). VS Code is installing a small server on the Linux side that the desktop VS Code will then talk to.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/vscode-server.png\" alt=\"The vscode server architecture diagram\" width=\"968\" height=\"404\" class=\"aligncenter size-full wp-image-4894\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/vscode-server.png 968w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/vscode-server-300x125.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/vscode-server-768x321.png 768w\" sizes=\"(max-width: 968px) 100vw, 968px\" \/><\/p>\n<p>That server will then install and host extensions in WSL, so that they run in the context of the tools and frameworks installed in WSL. In other words, your Python extension will run against the Python installed in WSL, not against what is installed on the Windows side, as it should for the proper development experience.<\/p>\n<p>The next thing that happens is VS Code will start and open the helloWorld folder. You may see a quick notification telling you that VS Code is connecting to WSL, and you may be prompted to allow access to the Node.js-based server.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/installing-vscode-server.png\" alt=\"Installing VSCode server dialogue box\" width=\"454\" height=\"45\" class=\"aligncenter size-full wp-image-4899\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/installing-vscode-server.png 454w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/installing-vscode-server-300x30.png 300w\" sizes=\"(max-width: 454px) 100vw, 454px\" \/><\/p>\n<p>Now, when we hover over hello.py, we get the proper Linux path.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/show-linux-path.png\" alt=\"The VSCode IDE using Linux paths\" width=\"556\" height=\"385\" class=\"aligncenter size-full wp-image-4893\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/show-linux-path.png 556w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/show-linux-path-300x208.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/p>\n<h2>Integrated Terminal<\/h2>\n<p>If that doesn&#8217;t convince you we&#8217;re connected to the Linux subsystem, run <strong>Terminal<\/strong> > <strong>New Terminal<\/strong> (Ctrl+`) to open a new terminal instance.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/new-terminal-in-wsl.png\" alt=\"The integrated terminal in VSCode running bash\" width=\"771\" height=\"181\" class=\"aligncenter size-full wp-image-4881\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/new-terminal-in-wsl.png 771w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/new-terminal-in-wsl-300x70.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/new-terminal-in-wsl-768x180.png 768w\" sizes=\"(max-width: 771px) 100vw, 771px\" \/><\/p>\n<p>You&#8217;ll start a new instance of the bash shell in WSL, again from VS Code running on Windows.<\/p>\n<p><strong>Tip<\/strong>: In the lower left corner of the Status Bar, you can see that we&#8217;re connected to our <strong>WSL: Ubuntu<\/strong> instance.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-status-bar.png\" alt=\"VSCode&#039;s WSL Remote status bar\" width=\"610\" height=\"183\" class=\"aligncenter size-full wp-image-4897\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-status-bar.png 610w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-status-bar-300x90.png 300w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/p>\n<p>Click on it to bring up a set of Remote &#8211; WSL extension commands.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-commands.png\" alt=\"The VSCode editor showing the Remote WSL Commands available\" width=\"1198\" height=\"490\" class=\"aligncenter size-full wp-image-4888\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-commands.png 1198w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-commands-300x123.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-commands-768x314.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/remote-wsl-commands-1024x419.png 1024w\" sizes=\"(max-width: 1198px) 100vw, 1198px\" \/><\/p>\n<h2>Installing the Python extension (and additional tools)<\/h2>\n<p>Click on hello.py to open it for editing. We are prompted with what we call an &#8220;Important&#8221; extension recommendation, in this case to install the Python extension, which will give us rich editing and debugging experiences. Go ahead and select <strong>Install<\/strong> and reload if prompted.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-extension-recommendation.png\" alt=\"The VSCode Remote recommendation to install python extension\" width=\"903\" height=\"178\" class=\"aligncenter size-full wp-image-4886\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-extension-recommendation.png 903w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-extension-recommendation-300x59.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-extension-recommendation-768x151.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<p>To prove that the extension is installed in WSL, open the Extensions view again (Ctrl+Shift+X). You will see a section titled <strong>WSL \u2013 Installed<\/strong> and you can see any extensions that are installed on the WSL side.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-installed-extensions.png\" alt=\"The extensions installed in WSL in VSCode Remote\" width=\"1892\" height=\"649\" class=\"aligncenter size-full wp-image-4896\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-installed-extensions.png 1892w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-installed-extensions-300x103.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-installed-extensions-768x263.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/wsl-installed-extensions-1024x351.png 1024w\" sizes=\"(max-width: 1892px) 100vw, 1892px\" \/><\/p>\n<p>Upon reload, you&#8217;ll also get prompted telling you that the pylint linter is not installed. Linters are used to give us errors and warnings in our source code. Go ahead and select <strong>Install<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-not-installed.png\" alt=\"VSCode dialogue showing that Pylint is not installed\" width=\"903\" height=\"180\" class=\"aligncenter size-full wp-image-4885\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-not-installed.png 903w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-not-installed-300x60.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-not-installed-768x153.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/p>\n<p>Now, when you edit your code, you get rich colorization and completions.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-intellisense.png\" alt=\"The VSCode IDE showing Python intellisense in VS code remote\" width=\"856\" height=\"501\" class=\"aligncenter size-full wp-image-4887\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-intellisense.png 856w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-intellisense-300x176.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/python-intellisense-768x449.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/p>\n<p>And when you save your file (Ctrl+S), you&#8217;ll get linting errors and warnings on the file.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-error.png\" alt=\"VSCode IDE showing an error with pylint\" width=\"727\" height=\"178\" class=\"aligncenter size-full wp-image-4884\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-error.png 727w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/pylint-error-300x73.png 300w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/p>\n<h2>Debugging<\/h2>\n<p>With our tools set up, let&#8217;s take this one step further. Set a breakpoint on line 1 of hello.py by clicking in the gutter to the left of the line number or by putting the cursor on the line and pressing F9.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/set-breakpoint.png\" alt=\"Setting a breakpoint in the VSCode IDE\" width=\"912\" height=\"210\" class=\"aligncenter size-full wp-image-4892\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/set-breakpoint.png 912w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/set-breakpoint-300x69.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/set-breakpoint-768x177.png 768w\" sizes=\"(max-width: 912px) 100vw, 912px\" \/><\/p>\n<p>Now, press F5 to run your application. You will be asked how to run the application, and since this is a simple file, just choose <strong>Python File<\/strong>.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-debug-config.png\" alt=\"Selecting the debug configuration in the VSCode IDE\" width=\"889\" height=\"356\" class=\"aligncenter size-full wp-image-4890\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-debug-config.png 889w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-debug-config-300x120.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/select-debug-config-768x308.png 768w\" sizes=\"(max-width: 889px) 100vw, 889px\" \/><\/p>\n<p>The app will start, and you&#8217;ll hit the breakpoint. You can inspect variables, create watches, and navigate the call stack.<\/p>\n<p>Press F10 to step and you&#8217;ll see the output of the print statement in the debug console.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/debug-view.png\" alt=\"The VSCode IDE debug view\" width=\"2032\" height=\"1698\" class=\"aligncenter size-full wp-image-4898\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/debug-view.png 2032w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/debug-view-300x251.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/debug-view-768x642.png 768w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/debug-view-1024x856.png 1024w\" sizes=\"(max-width: 2032px) 100vw, 2032px\" \/><\/p>\n<p>You get the full development experience of Visual Studio Code, using the Linux instance installed in WSL.<\/p>\n<p>If you want to open another folder in WSL, open the <strong>File<\/strong> menu and choose <strong>Open Folder<\/strong>. You&#8217;ll get a minimal file and folder navigator for the Linux file system, not the Windows file system.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/open-folder.png\" alt=\"Opening another folder in the VSCode IDE\" width=\"887\" height=\"318\" class=\"aligncenter size-full wp-image-4883\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/open-folder.png 887w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/open-folder-300x108.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/open-folder-768x275.png 768w\" sizes=\"(max-width: 887px) 100vw, 887px\" \/><\/p>\n<p>If you want to switch back to the Windows, select the <strong>Show Local<\/strong> option and you&#8217;ll get the standard Windows File Open dialog.<\/p>\n<h2>In conclusion<\/h2>\n<p><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2019\/07\/magic.gif\" alt=\"Shia Labeouf showing magic\" width=\"275\" height=\"252\" class=\"aligncenter size-full wp-image-4905\" \/> <em><a href=\"https:\/\/giphy.com\/gifs\/shia-labeouf-12NUbkX6p4xOO4\">Source<\/a><\/em><\/p>\n<h2>More information<\/h2>\n<p>With WSL, VS Code and the Remote \u2013 WSL extension, your Windows machine becomes an awesome box for developing Linux applications. Your tools run on Windows while your application runs where it will be deployed, on Linux.<\/p>\n<p>Linux development is not limited to WSL. Using the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-vscode-remote.remote-ssh\">Remote \u2013 SSH extension<\/a>, you can develop against remote SSH hosts with the same fidelity as shown here, all from your Windows desktop.<\/p>\n<p>For more information, check out the following resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/remote\/remote-overview\">Remote development overview<\/a><\/li>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/remote\/wsl\">Remote WSL documentation<\/a><\/li>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/remote\/containers\">Remote development with Docker Containers<\/a><\/li>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/remote\/ssh\">Remote development over SSH<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/get-started-with-windows-subsystem-for-linux\">WSL Microsoft Learning module<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/windows\/wsl\/install-win10\">Windows Subsystem for Linux documentation<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/python\/get-started\/python-for-web\">Get started with Python in Visual Studio Code<\/a><\/li>\n<\/ul>\n<p>Finally, if you really want to supercharge your Windows dev box, try out the new <a href=\"https:\/\/devblogs.microsoft.com\/commandline\/introducing-windows-terminal\">Windows Terminal<\/a>!<\/p>\n<p>Happy Coding!<\/p>\n<p>This is part 2 of our 3 part series. You can find the full series here:<\/p>\n<ul>\n<li>Part 1 &#8211; <a href=\"https:\/\/devblogs.microsoft.com\/commandline\/take-your-linux-development-experience-in-windows-to-the-next-level-with-wsl-and-visual-studio-code-remote\/\">Take your Linux development experience in Windows to the next level with WSL and Visual Studio Code Remote<\/a><\/li>\n<li><strong>Part 2 &#8211; <a href=\"https:\/\/devblogs.microsoft.com\/commandline\/an-in-depth-tutorial-on-linux-development-on-windows-with-wsl-and-visual-studio-code\/\">An In Depth Tutorial on Linux Development on Windows with WSL and Visual Studio Code<\/a><\/strong><\/li>\n<li>Part 3 &#8211; <a href=\"https:\/\/devblogs.microsoft.com\/commandline\/tips-and-tricks-for-linux-development-with-wsl-and-visual-studio-code\/\">Tips and Tricks for Linux development with WSL and Visual Studio Code<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In an earlier blog post, Take your Linux development experience in Windows to the next level with the Windows Subsystem for Linux (WSL) and Visual Studio Code Remote, we introduced an overview of the VS Code Remote &#8211; WSL extension, which simplifies Linux development on Windows Subsystem on Linux (WSL). Put on your SCUBA gear, [&hellip;]<\/p>\n","protected":false},"author":2191,"featured_media":4849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3,9],"tags":[],"class_list":["post-4877","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-tools","category-bash-on-ubuntu-on-windows"],"acf":[],"blog_post_summary":"<p>In an earlier blog post, Take your Linux development experience in Windows to the next level with the Windows Subsystem for Linux (WSL) and Visual Studio Code Remote, we introduced an overview of the VS Code Remote &#8211; WSL extension, which simplifies Linux development on Windows Subsystem on Linux (WSL). Put on your SCUBA gear, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts\/4877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/users\/2191"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/comments?post=4877"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts\/4877\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/media\/4849"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/media?parent=4877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/categories?post=4877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/tags?post=4877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}