如何将 PyCharm 与 Google 计算引擎一起使用 [英] How to use PyCharm with Google compute engine

查看:33
本文介绍了如何将 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. 为 GCP 上的远程计算机分配一个公共 IP.
  2. 运行 gcloud compute config-ssh 自动将您项目的虚拟机添加到您的 ~/.ssh/config 或手动将您的虚拟机的公共 IP 添加到它.如果您跳过了第 1 步,那么您必须在每次重新启动远程 VM 时运行 gcloud compute 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 的 Deployment 配置中使用要连接的远程的 Host 名称
  • 添加远程解释器:从下拉列表中选择远程服务器(之前创建的)并将 PyCharm 指向 Python 安装的可执行 python.
  • 完成
  • 这篇关于如何将 PyCharm 与 Google 计算引擎一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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