PyCharm remote interpreter with SSH (WSL2, venv, pyenv)

Overview



Start SSH server with bash (WSL)

bash


sudo service ssh start
ssh 127.0.0.1

#If that doesn't work, try the following:
sudo ssh-keygen -A
sudo service ssh restart
ssh 127.0.0.1


Launch a virtual environment from bash (WSL)

Launch the project directory in PyCharm Professional, open terminal and switch to bash

cmd@/Users/~/{project-dir}


bash

Like bash @ / mnt / c / Users / ~~ / {project-dir}, The current directory moves to the location where the directory that started bash is mounted.

Create a virtual environment from bash

bash@/mnt/c/Users/~~/{project-dir}


#If you are using pyenv"home/.pyenv/shims/python"Point to(global python)
python which

#Confirmation of global version
python --version

#If you want to use a different version, specify the local version here
pyenv local {version}

# bash(WSL)Create venv from(If there is an existing venv created from cmd or ps, create it with a name that will not be covered)
python -m venv {venv-name}
Start venv

bash@/mnt/c/Users/~~/{project-dir}


#start venv
. {venv-name}/bin/activate

# "/mnt/c/Users/~~/{venv-name}/bin/python"Point to(Virtual environment python)
python which
pip install --upgrade pip


Make an SSH connection with PyCharm and set up Remote Interpreter



Package installation

bash@/mnt/c/Users/~~/{project-dir}


pip install -r requirements.txt


【important point】

Recommended Posts

PyCharm remote interpreter with SSH (WSL2, venv, pyenv)
python with pyenv and venv
Use AWS interpreter with Pycharm
Use pydoc with Virtualenv / pyenv / venv
[ev3dev × Python] SSH Control (remote control with keyboard)
Log in to the remote server with SSH
Build a virtual environment with pyenv and venv
Ssh to virtual environment with remote development of vscode