Skip to content Skip to sidebar Skip to footer

Eclipse Pydev Use Remote Interpreter

is there a posibility to make eclipse PyDev use a remote Python interpreter? I would like to do this, as the Linux Server I want to connect to has several optimization solvers (CPL

Solution 1:

Unfortunately no. You can remotely connect to your Linux server via Remote System Explorer (RSE). But can't use it as a remote interpreter. I use Pycharm. You can use the free Community Edition or the Professional Edition for which you have to pay for it. It is not that expensive and it has been working great for me.

Solution 2:

As Adel says, this is probably not possible with the Remote System Explorer, or the normal Run button, but you can automate the process you currently use. I had to do this for a few weeks when the fan was broken in my laptop, and doing any significant computation there made it overheat and poweroff, so I just ran everything on my work machine.

You can use the External Tools mechanism to run a short script that syncs your code to the remote server, runs your script, then syncs back any output files to your local machine. My script looks like this, is stored in $HOME/bin/runremote.sh, and is executable (chmod +x runremote.sh)

fp="$1"# Local path to the script we want to run--for now,# this is the only command I pass in from Eclipse, but you could add others if so inclined.# My home directory is a little different on my local machine than on the remote,# but otherwise things are in the same place. Adjust as needed.
fp=`python -c "print '$fp'.replace('/home/tsbertalan', '/home/oakridge/bertalan')"`

# Run the synchronization. I use Unison, but you could use something else,# like two calls to rsync, or a series of scp commands.
reposync >/dev/null  # The redirection assumes your sync command will print errors properly on stderr.cd='cd '`dirname$fp`

# I use a virtual environment on the remote server, since I don't have root access to install# packages globally. But this could be any set-up command you want to run on the remote.# A good alternative would be `source $HOME/.profile` or `~/.bashrc`.
act='source /home/oakridge/bertalan/bin/activate'
fname="`basename $fp`"
cmd="$act ; $cd ; python $fname"# Run the command remotely. The -X forwards X11 windows, so you can see your Matplotlib plots.# One difficulty with this method is that you might not see all your output just as it is created.
ssh bertalan@remote.server.edu -X  "$cmd"sleep 1

# My synchronization script is bidirectional, but you could just use rsync with the arguments flipped.
reposync >/dev/null

If you don't use linux or OSX locally, you'll probably have to use MinGW or Cygwin or whatever to get this working. Or, since you appear to have a working Python interpreter, you could write an equivalent script in Python, make it executable (by the file properties dialog in Explorer, I think), and add a #!/path/to/python line at the top. I don't use Windows regularly, so I can't really help with that.

To use this in Eclipse, go to Run > External Tools > External Tools Configurations.... Add a new tools whose Location is the path to your script, and whose first Argument is ${resource_loc}. You can then use it with Run > External Tools > [first item], or bind it to a keyboard shortcut (I used F12) by going to Windows > Preferences > Keys, and searching for "Run Last Launched External Tool". Presumably you'll have to go through the menus first to make this the "Last Launched" external tool.

Post a Comment for "Eclipse Pydev Use Remote Interpreter"