如何在Google计算引擎中使用PyCharm [英] How to use PyCharm with Google compute engine

查看:87
本文介绍了如何在Google计算引擎中使用PyCharm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Google云平台上运行的计算引擎实例.

I have a compute engine instance running on Google cloud platform.

我想将计算引擎的Python解释器用作Pycharm的远程解释器.这意味着我将在本地计算机上使用Pycharm并远程运行计算.

I would like to use the Python interpreter of the compute engine as a remote interpreter with Pycharm. This means that I would be using Pycharm on my local machine and running computations remotely.

关于如何实现这一目标的任何线索?

Any clue on how to achieve this?

推荐答案

以下要求,例如 James Hirschhorn 指出了PyCharm的专业版.

The following requires, as James Hirschhorn pointed out, the Professional verison of PyCharm.

  1. 将公共IP分配给GCP上的远程计算机.
  2. 运行 gcloudcompute config-ssh 将项目的VM自动添加到〜/.ssh/config 或手动将VM的公共IP添加到其中.如果跳过了步骤1,则每次重新启动远程VM时,都必须运行 gcloudcompute config-ssh ,因为它始终会分配一个新的IP.〜/.ssh/config 填充了许多以下格式的条目:
  1. Assign a public IP to the remote machine on GCP.
  2. Run gcloud compute config-ssh to automatically add the VMs of your project to your ~/.ssh/config or manually add the public IP of your VM to it. If you skipped step 1. then you have to run gcloud compute config-ssh every time you re-start the remote VM, because it always gets a new IP assigned. The ~/.ssh/config gets populated with many entries in the following format:
Host the-vm-host-name  # use this in PyCharm's Host field
    HostName 123.456.789.00  # the VM's IP address

  • 在PyCharm的部署"配置中使用要连接的远程服务器的 Host 名称
  • 添加远程解释器:从下拉列表(先前创建的服务器)中选择远程服务器,然后将PyCharm指向Python安装的可执行文件 python .
  • 完成
  • 这篇关于如何在Google计算引擎中使用PyCharm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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