Configure an interpreter using WSL
You can use Windows Subsystem for Linux (WSL) to work with a Python interpreter available in your Linux distribution.
Fulfill the preliminary steps
Ensure that you have downloaded and installed Python on your computer.
Click the Windows button in the lower-left corner of the screen and start typing
System Information. To ensure that your system works well with WSL, upgrade your Windows to the latest available version.
Install the Windows Subsystem for Linux and initialize your Linux distribution as described in the WSL Installation Guide.
If your Linux distribution doesn't come with rsync, you need to install it:
sudo apt install rsync
Configure remote interpreter via WSL
Press Ctrl+Alt+S to open the project Settings/Preferences.
In the Settings/Preferences dialog Ctrl+Alt+S, select . Click the icon and select Add.
In the left-hand pane of the dialog, click WSL.
Select the Linux distribution and specify the path to the python executable in the selected Linux distribution. Typically, you should be looking for wsl.exe but you can specify any non default WSL distro.
Once done, the new interpreter will be added to your project, and the default mnt mappings will be set.
Note that with WSL you cannot create virtual environments: all packages you install will be added to the corresponding system interpreter. You will be asked to enter your sudo password.
PyCharm allows you to use custom Linux distributions run on WSL. This can be done by editing the wsl.distributions.xml configuration file created by PyCharm automatically after detecting WSL.
Add a custom distribution
Open the %APPDATA%\JetBrains\<product><version>\config\options\wsl.distributions.xml file.
descriptorelement and provide settings to access your custom distribution. Note that the
idvalue should be unique. For example:<!-- ... --> <descriptor> <id>Arch</id> <microsoft-id>Arch</microsoft-id> <executable-path>c:/linux/arch.exe</executable-path> <presentable-name>Arch</presentable-name> </descriptor> <!-- ... -->
Consult the Windows registry to check the id and executable-path values.
Restart PyCharm and add your custom distribution as a remote interpreter as described above.
To run Terminal in WSL configuration, open project Settings/Preference (Ctrl+Alt+S) and go to .
wsl.exein the Shell path field and click Ok.
Switch to the Terminal tool window and type any command to inspect the output.
Configure system settings to enable debugging
Perform the following steps to ensure that the debugger works properly:
Run the Windows PowerShell as administrator.
Execute the following command to allow connections using WSL:New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
Then execute the command to renew the firewall rules:Get-NetFirewallRule | where DisplayName -ILike "*PyCharm*" | Remove-NetFirewallRule
Now start the debugger session. When the Windows Firewall popup appears, select the Public networks checkbox.