使用Pydev和RSE Server在远程Linux机器上定义远程解释器 [英] Define remote interpreter on remote Linux machine using Pydev and RSE Server

查看:146
本文介绍了使用Pydev和RSE Server在远程Linux机器上定义远程解释器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Eclipse安装在Windows上,按照这个eclipse page 。我设法建立一个在Linux机箱上运行的RSE服务器;我也可以在远程机器上创建一个项目。



实际上,我在Linux上使用虚拟环境,我想在开发过程中选择它们。



有没有办法为PyDev或Django项目定义一个远程解释器

解决方案

我曾经在Ubuntu虚拟机中与远程python解释器有同样的问题。我想你应该可以通过你的情况下的 ssh 连接。



尽管Pycharm可以使用远程解释器(即使使用虚拟机也可使用 Vagrant ),像我这样的人喜欢编辑器,如升华文本3 ,即不是IDE。在那里,您可以指定主机中任何解释器的路径。我猜Pydev还允许在主机内指定一个python解释器。



我可以找到使用远程解释器的最简单的方法(但可能不是最好的)是在主机中安装虚拟机的环境文件夹(python可执行文件和模块的位置)。所以,您可以执行以下操作:


  1. 在虚拟机中(客人) >在您想要的任何路径中创建一个虚拟环境,例如〜/ myGuestEnvs / testEnv / 。您可以使用 virtualenv 来执行此操作,您以前使用 pip 安装


  2. 在您的主机中 - >安装 win-sshfs ,并将您的主机中的虚拟机的对应文件夹挂载到这个〜/ myGuestEnvs / testEnv / - > 〜/ myHostMountedFolder / 。如果我的理解很好,你是从Windows编写的,并在Linux上运行代码。我必须承认,通过Windows上的 ssh 安装磁盘不是最简单的,但仍然可能!您可以查看此SoF问题其他方式。


  3. 始终在您的主机中 - >将您的python解释器指向已挂载的文件夹: python_interpreter - > 〜/ myHostMountedFolder / bin / python




    1. 谨慎,如果您只挂载/指向环境的 bin 文件夹, python可执行文件是,您将丢失IDE的所有代码完成, goto定义 ...的可用性,因为它将无法找到导入的模块。 / p>

      我应该补充说,如果虚拟机关闭,那么Pydev将无法使用python_interpreter,因为挂载的文件夹将为空。每次你编写代码,你将不得不启动虚拟机,如果没有,那么可能使用默认的主机python解释器和主机python包。


      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?

      解决方案

      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.

      这篇关于使用Pydev和RSE Server在远程Linux机器上定义远程解释器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆