Configuring Visual Studio 2022 to develop Python projects in WSL2

I installed WSL2 and use Visual Studio (VS) 2022 on the windows. I want to configure my VS 2022, so I can develop Python projects in WLS2. All tutorials I find online only talks about visual studio code. I don't want to install another IDE. Does anybody know how to do that or point me to some material?

Upvotes: 2

Views: 2057

Answers (3)

Taylor de Vos
Taylor de Vos

Reputation: 1

Answering this late because there is a workaround possible if you want to use Visual Studio debugging tools with Python and WSL2.

You cannot natively run WSL2 Python projects in Visual Studio, but you can run your Python code in WSL2 with debugpy, attach it as a "remote" process in the "debug->Attach to Process" section, and then debug in Visual Studio. Make sure you have identical copies of your files and folder structure in WSL2 and your Visual Studio Python project. See this guide for more details:

https://learn.microsoft.com/en-us/visualstudio/python/debugging-python-code-on-remote-linux-machines?view=vs-2022

Upvotes: 0

aquaplane
aquaplane

Reputation: 127

Not sure if VS is available for Linux or WSL2 yet.

If you look at https://visualstudio.microsoft.com/downloads/, only Windows & Mac seem to be supported.

So you have 2 main options:

  1. Use VS on Windows itself. Then you just need to install the Python Tools for Visual Studio (PTVS) to be able to support Python development
  2. Use VS Code on WSL2 - it's pretty lightweight to install anyway as a code editor, but can be endowed with comparable features to VS

EDIT: It may be that I'm misunderstanding the question as pointed out below by NotTheDr01ds, and instead you want to target WSL2 from the VS IDE, developing Python.

Upvotes: 0

NotTheDr01ds
NotTheDr01ds

Reputation: 20630

Unfortunately not at this time, no. The VSCode integration with WSL is done through the use of an extension that creates an interop server between Windows VSCode and the Linux side of WSL. There isn't an extension like that for Visual Studio, however.

The only WSL integration that I'm aware of in Visual Studio 2022 is the inclusion of a WSL toolchain that allows you to target WSL/Linux in C++ projects. But nothing that I'm aware of for Python, no.

I believe you'll need to install an additional IDE to get Python/WSL support, sorry.

Upvotes: 1

Related Questions