Setup remote interpreter (virtualenv) in VM or container for PyCharm

If you are developing with a virtual machine or container, any modules installed by PIP will either be installed globally or potentially in a virtualenv location outside of the project root. Therefore you will need to tell PyCharm that the imported modules you’re using are located remotely, not locally.

First you will need to go into Preferences/Settings and to the Project specific settings, then into the Interpreter section.

You will then be able to add a Remote Interpreter, which will be the credentials required to log into your VM or container via SSH by PyCharm.

If you are using Vagrant then the location of the SSH key that can be used to login to the VM can be found by using the vagrant ssh-config command, which will output something like this.

The location of the SSH key used by the vagrant ssh command is by the IdentityFile key.

Add comment