Using SSH to created a WSL-based Remote Interpreter
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
sudo pacman -S rsync
Configure remote interpreter via WSL
Do one of the following:
Click the Python Interpreter selector and choose Add New Interpreter.
Press Ctrl+Alt+S to open the project Settings/Preferences and go to . Click the Add Interpreter link next to the list of the available interpreters.
Select On WSL from the list of available interpreter types:
Wait until PyCharm detects Linux on your machine and completes introspection. Press Next to proceed:
In the left-hand pane of the dialog, select the type of the WSL interpreter you want to create: Virtual Environment or System Interpreter.
For a system interpreter, just provide the path to the Python executable in the selected Linux distribution.
For virtual environments, you can provide a path to a Python executable of an existing environment in the selected Linux distribution or create a new environment based on the specified Python.
Once done, the new interpreter will be added to your project, and the default mnt mappings will be set.
PyCharm allows you to use custom Linux distributions run on WSL. PyCharm auto-detects such a distribution and adds it to the Linux Distribution list:
Create a WSL-based interpreter for a directory in \\wsl$
If you have any directory with some Python files in
\\wsl$, you can open this directory in PyCharm. The IDE will create a project and suggest creating a WSL-based interpreter.
Selectfrom the main menu. Choose a directory in
If PyCharm cannot discover any pre-configured WSL interpreter, you will see the banner prompting to discover Python in the Ubuntu installation:
Click Search for Python in Ubuntu to find a Python executable and create a WSL-based interpreter.
Once the interpreter is created, PyCharm notifies you.
Configure Terminal in WSL
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 Security Alert popup appears, select the Public networks checkbox.