Configuring Remote Interpreters via WSL
On this page:
Overview
PyCharm can be configured to use WSL as remote interpreter, but without deployment, since each drive on Windows
is mapped to the appropriate folder in /mnt/<DRIVE_NAME>
in WSL.
So, only mappings need to be configured.
Use 127.0.0.1
as the host name, and login and password entered after first
lxrun /install
. Also, set C:\
to /mnt/c/
in the mappings.
Prerequisites
Make sure that the following prerequisites are met:
- Win10 build
14361
or later is installed. It is also possible to upgrade the current Insider Preview. - WSL is installed (like
lxrun /install
orlxrun /update
)
Running SSH on WSL
- Run
bash.exe
. - Update to latest version
sudo apt-get update
orsudo apt-get upgrade
. - Open
/etc/ssh/sshd_config
file for editing:- Enable password authentication (unless you want to use the public keys): set
PasswordAuthentication
toyes
. - Since
chroot
is not implemented in WSL, you also need to setUsePrivilegeSeparation
tono
.
Save changes and close
sshd_config
. - Enable password authentication (unless you want to use the public keys): set
- Type
sudo $(sudo which sshd) -d
to run OpenSSH in the foreground. You should see something like "Server listening on <server> port <number>" - From another
bash.exe
session, tryssh 127.0.0.1
. - If you see a message about ECDSA encryption algorithm fingerprint, answer
y
. Password prompt appears, which means that the server works correctly. - Turn it off with Ctrl+C, and type the command
sudo service ssh start
to start the server in daemon mode. Looks like upstart is broken in the current WSL, so you would need to runbash.exe
, startsshd
and keep console window opened, since WSL stops when the last client disconnects. You may createwsl_ssh.bat
file likebash.exe -c "sudo service ssh start &&& sleep 999d"
and use it to launch ssh.
Now that SSH is running, you can configure the remote interpreter.
Configuring WSL as remote interpreter
To configure WSL as the remote interpreter, follow these steps
- In the Project Interpreter page of the Settings/Preferences dialog box, click .
- From the drop-down list, choose .
- In the dialog box Configure Remote Python Interpreter, click the radio-button SSH credentials:
- In the Configure Remote Python Interpreter dialog box, fill in the server
information (host=
localhost
or127.0.0.1
, port =22
, user name and password used on first launch oflxrun /install
.) - The Python interpreter path field displays the path to the desired Python executable. You can accept default, or specify a different one.
- Click OK in the Configure Remote Python Interpreter dialog box. The configured remote interpreter is added to the list.
Later, you can use this interpreter as the project interpreter. The only difference lays with path mappings.
To configure path mappings, follow these steps
- Next to the Path mappings field, click . Edit Project Path Mappings Dialog opens.
- In this dialog box, map local paths to remote ones (for example, map
C:\
to/mnt/c/
):Several mappings are delimited with semicolons.
- Click OK when ready.
See Also
Language and Framework-Specific Guidelines:
External Links:
Last modified: 23 December 2016