![]() ![]() Tip: In the lower left corner of the Status Bar, you can see that you're connected to your WSL: Ubuntu instance.Įdit and debug Installing the Python extension (and additional tools)Ĭlick on hello.py to open it for editing. ![]() You'll start a new instance of the bash shell in WSL, again from VS Code running on Windows. Run Terminal > New Terminal ( ⌃` (Windows, Linux Ctrl+`)) to open a new terminal instance. Now, when you hover over hello.py, you get the proper Linux path. 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. The next thing that happens is VS Code will start and open the helloWorld folder. In other words, your language extensions will run against the tools and frameworks installed in WSL, not against what is installed on the Windows side, as it should for the proper development experience. 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. VS Code is installing a small server on the Linux side that the desktop VS Code will then talk to. The first thing you'll see is a message about "Installing VS Code Server" (the c7d83e57… number is the version of the VS Code Server that matches the client-side tools you just installed). Note: If this command does not work, you may need to restart your terminal, or you may not have added VS Code to your path when it was installed. If you use the Insiders version of VS Code, you will have to run 'code-insiders. ![]() The '.' argument tells VS Code to open the current folder. In the WSL terminal, make sure you are in the helloWorld folder, and type in 'code. And that defeats the purpose of having an isolated Linux instance set up with all your Python tools and runtimes! Run in WSL Remember, Python is installed in the Linux distro, which means if you're editing Python files on the Windows side, you can't run or debug them unless you install the same Python development stack on Windows. The problem with this model is that the Python runtime, pip, or any conda packages for that matter, are not installed on Windows. You can run Vim in the terminal to edit your file, or you can edit the sources on the Windows side through the \\wsl$ mount: 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. Create a new folder called "helloWorld" and then add a Python file that will print a message when run: mkdir helloWorld & cd helloWorld echo 'print("hello from python on ubuntu on windows!")' > hello.py python3 hello.py Start with the canonical "Hello World" app. sudo apt update sudo apt install python3 python3-pip If you don't have Python already installed, run the following commands to install Python3 and pip, the package manager for Python, into your Linux installation. You'll need to create a user ID and password since you are setting up a full Linux instance. This will open a Linux terminal and complete the installation. Choose the Linux distribution you want to install (for example Ubuntu) and follow the prompts.Īnd when done, select Launch to get started. You can use the store app, or search for a Linux distro in the Windows search bar. You install Linux distributions for WSL from the Microsoft Store. WSL is enabled, but you haven't installed a Linux distribution yet. If you prefer, you can open PowerShell as an Administrator and type: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-LinuxĪfter the command runs, you will be prompted to restart Windows.Īfter restarting Windows, you can check that you have WSL enabled by opening a Command Prompt and typing 'wsl'. Select OK and you will be prompted to restart Windows. ![]() Scroll down and check Windows Subsystem for Linux. In the Windows search bar, type 'features' to bring up the Turn Windows Features on and off dialog. You can enable it through the Windows Features dialog or PowerShell. Windows Subsystem for Linux (WSL) is an optional feature on Windows 10. The Remote Status bar item can quickly show you in which context VS Code is running (local or remote) and clicking on the item will bring up the WSL extension commands. With the WSL extension installed, you will see a new Status bar item at the far left. The WSL extension enables you to run Visual Studio Code within the Windows Subsystem for Linux (WSL). This tutorial walks you through enabling Windows Subsystem for Linux (WSL) and running Visual Studio Code in WSL using the WSL extension. Configure IntelliSense for cross-compiling. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |