【发布时间】:2019-08-28 03:43:05
【问题描述】:
我使用包 remote_ikernel 自动从 azure VM 连接到 azure VM。这两个系统是相同的,即它们具有相同的python环境。
我使用
启动远程内核ssh -oStrictHostKeyChecking=no {username}@{ip} sudo /anaconda/envs/py36/bin/ipython kernel
然后通过在下面的脚本中填写参数来更新我的本地kernel.json。
{{
"argv": [
"/anaconda/envs/py35/bin/python",
"-m",
"remote_ikernel",
"--interface",
"ssh",
"--host",
"{username}@{ip}",
"--kernel_cmd",
"/anaconda/envs/{remote_python}/bin/ipython kernel -f {{host_connection_file}}",
"{{connection_file}}"
],
"display_name": "SSH {username}@{kernel_name}",
"remote_ikernel_argv": [
"/anaconda/envs/py35/bin/remote_ikernel",
"manage",
"--add",
"--kernel_cmd=/anaconda/envs/{remote_python}/bin/ipython kernel -f {{connection_file}}",
"--name=Remote VM",
"--interface=ssh",
"--host={username}@{ip}"
]
}}
第一次尝试
但是,我们不想使用远程/anaconda/envs/py35/bin/python,而是使用它的py36 兄弟。我希望通过在第一个命令中调整它来解决这个问题,但这并不能解决它。更改 kernel.json 中的任何 py35 也无济于事。我们怎样才能做到这一点?
第二次尝试(编辑)
我调整了 kernel.json 以包含指向 py36 环境的指针。请参阅上面的更新版本。下面的日志看起来不错,但import sys; sys.executable 仍然显示py35 版本。
[I 11:54:57.549 remote_ikernel] Launching kernel over SSH.
[I 11:54:57.549 remote_ikernel] Login command: 'ssh -o StrictHostKeyChecking=no username@ip'.
[I 11:54:57.889 remote_ikernel] Established connection; starting kernel.
[I 11:54:57.889 remote_ikernel] Current working directory /data/projects/...
[I 11:54:58.040 remote_ikernel] Running kernel command: '/anaconda/envs/py36/bin/ipython kernel -f ./rik_kernel-40d44e0d-4dac-4939-b018-74f4c82b6855.json'.
[I 11:54:59.357 NotebookApp] Adapting to protocol v5.1 for kernel 40d44e0d-4dac-4939-b018-74f4c82b6855
[I 11:54:59.358 NotebookApp] Restoring connection for 40d44e0d-4dac-4939-b018-74f4c82b6855:d877b8cff59245bf9ca5811d9310ee7f
[I 11:54:59.358 NotebookApp] Replaying 7 buffered messages
[I 11:55:28.382 remote_ikernel] Setting up tunnels on ports: 57033, 45674, 57305, 38105, 56085.
显示远程内核文件
{
"shell_port": 45674,
"iopub_port": 57305,
"stdin_port": 38105,
"control_port": 56085,
"hb_port": 57033,
"ip": "127.0.0.1",
"key": "9e336436-...",
"transport": "tcp",
"signature_scheme": "hmac-sha256",
"kernel_name": ""
}
【问题讨论】:
标签: python python-3.x jupyter-notebook