18

I have a Windows box and a Linux red hat box.

Eclipse is installed on Windows, following instructions given on this eclipse page. I managed to set up a RSE server that runs on the Linux box; I am also able to create a project on the remote machine.

Actually I am using virtual environments on Linux and I would like to select them when developing.

Is there a way to define a remote interpreter for a PyDev or Django project?

dry
  • 831
  • 2
  • 8
  • 21
  • 5
    If you ever get it working, do you mind posting your solution here? – exfizik Oct 25 '12 at 22:53
  • 1
    I'm afraid there is no possible to use remote interpreter for PyDev: [Eclipse PyDev use remote interpreter](http://stackoverflow.com/a/15360958/403616) – Jaime M. Dec 19 '13 at 10:35
  • this might be a stupid way, but you might be able to copy the interpreter onto your windows using something like scp if you have cygwin – user1948847 May 26 '14 at 18:59
  • possible duplicate of [Eclipse PyDev use remote interpreter](http://stackoverflow.com/questions/14716662/eclipse-pydev-use-remote-interpreter) – puredevotion Jul 13 '14 at 17:09
  • I have the following set up: Ubuntu 16.04-64 on host; LXC container running Ubuntu 16.04-64 connected through ssh; several django projects (pure django, django-cms, wagtail cms) located in separate dirs inside /home/ubuntu/dir1, dir2, dir3; – Dmitry Somov Aug 05 '18 at 10:38
  • I've posted my related question here: https://stackoverflow.com/questions/51693969/configuring-eclipse-pydev-to-work-with-projects-on-remote-server-and-remote-inte – Dmitry Somov Aug 05 '18 at 11:53

4 Answers4

6

I once had the same problem with a remote python interpreter inside an Ubuntu virtual machine. I guess you should be able to connect through ssh in your case also.

Although Pycharm can have remote interpreters (even with virtual machines using Vagrant), some people like me prefer editors like Sublime Text 3, i.e., not IDE. There, you can specify a path to any interpreter within your host machine. I guess Pydev also allows to specify a python interpreter inside the host.

The easiest way (but maybe not the nicest) I could find to use a remote interpreter, was to mount the environment folder (where the python executable and modules were) of the virtual machine in my host. So, here's what you can do:

  1. In the virtual machine (the guest) --> create a virtual environment in any path you want, for example, ~/myGuestEnvs/testEnv/. You can do this using virtualenv, which you previously installed with pip.

  2. In your host --> install win-sshfs and mount the correspondent folder of the virtual machine in your host like this ~/myGuestEnvs/testEnv/ --> ~/myHostMountedFolder/. If I understood well, you are coding from Windows and running the code on Linux. I must admit that it isn't the easiest to mount disks through ssh on Windows, but it still possible! You can check out this SoF question for other ways.

  3. Always in your host --> point your python interpreter to the mounted folder: python_interpreter --> ~/myHostMountedFolder/bin/python.

Careful, if you only mount/point the bin folder of the environment, where the python executable is, you will lost all the code completion, goto definition... usabilities of the IDE, since it won't be able to locate your imported modules.

I should add that if the virtual machine is down, then Pydev won't be able to use the python_interpreter since the mounted folder will be empty. Everytime you code, you will have to start the virtual machine, if not, then it is possible that the default host python interpreter and host python packages are used.

Community
  • 1
  • 1
tomasyany
  • 1,132
  • 3
  • 15
  • 32
  • I am having problem with 3 step, when I try to navigate to the mounted interpreter in windows in eclipse and select linux python interpreter i hit with the message could not add the linux python – louis Oct 23 '19 at 05:04
1

Pycharm IDE support running your project/program from Remote Interpreter also the support deploying to remote server(which comes as part of Pro version).

Pycharm also does support Git/Vagrant/GoogleApp Engine.

deeshank
  • 4,286
  • 4
  • 26
  • 32
0

The only product for Python I managed to get working in this manner (like Eclipse debugging remote code in Java) like this is (commercial, proprietary) WingIDE.

LetMeSOThat4U
  • 6,470
  • 10
  • 53
  • 93
0

I managed to achieve this by doing the following:

1) Create a python venv

python3 -m venv /home/me/venv

2) Set pydev interpreter to the venv by going to Window->Preferences->PyDev_Interpreters->Python Interpreter-> Browse for python/pypy

3) Backup the python executable if needed:

mv /home/me/venv/bin/python3 /home/me/venv/bin/python3.bkp

4) Create a new python executable with the same name:

nano /home/me/venv/bin/python3

5) Paste the following content:

#!/bin/bash

remote_username=me
remote_interpreter=python3
remote_hostname=10.0.0.1

file_path=(${2//$remote_hostname/ })

ssh $remote_username@$remote_hostname "$remote_interpreter $1 ${file_path[1]}"

6) Change remote_username, remote_interpreter and remote_hostname to match your configurations.

Enjoy !