gpt4 book ai didi

python - ipyparallel 异常 : "You have attempted to connect to an IPython Cluster but no Controller could be found"

转载 作者:行者123 更新时间:2023-12-05 06:38:45 29 4
gpt4 key购买 nike

我刚开始使用 ipyparallel,我正在使用 VS2017 并将其导入为;

import ipyparallel as ipp

然后尝试使用;

def main():
rc = ipp.Client()


if __name__ == "__main__":

main()

在 python 窗口中,我收到消息:“等待连接文件:~.ipython\profile_default\security\ipcontroller-client.json”

它卡在 rc = ip.Client() 行并给出问题中的异常。该位置似乎没有任何名为 profile_default 的文件,更不用说 json 文件了。

有人知道如何解决这个问题吗?

最佳答案

如果没有集群在运行,则会出现此错误。

import ipyparallel as ipp
rc = ipp.Client()

这是错误信息:

Waiting for connection file:~/.ipython/profile_default/security/ipcontroller-client.json


OSError Traceback (most recent calllast) in ----> 1 rc = ipp.Client()OSError: Connection file '~/.ipython/profile_default/security/ipcontroller-client.json' not found.You have attempted to connect to an IPython Cluster but no Controller could be found.Please double-check your configuration and ensure that a cluster is running.

这是一个显示正在运行的集群的函数:

def show_clusters():
clusters = ipp.ClusterManager().load_clusters()
print("{:15} {:^10} {}".format("cluster_id", "state", "cluster_file"))
for c in clusters:
cd = clusters[c].to_dict()
cluster_id = cd['cluster']['cluster_id']
controller_state = cd['controller']['state']['state']
cluster_file = getattr(clusters[c], '_trait_values')['cluster_file']
print("{:15} {:^10} {}".format(cluster_id, controller_state, cluster_file))

在这种情况下,没有集群在运行。

show_clusters()
# cluster_id state cluster_file

在 Jupyter 笔记本中,可以为集群启用一个选项卡(ipcluster nbextension enable)。这是没有集群运行时的样子:

no running cluster

启动集群

cluster = ipp.Cluster(n=4)
await cluster.start_cluster() # or cluster.start_cluster_sync() without await
# Using existing profile dir: '/Users/X/.ipython/profile_default'
# Starting 4 engines with <class 'ipyparallel.cluster.launcher.LocalEngineSetLauncher'>

show_clusters()
# cluster_id state cluster_file
# 1648935811-e7r2 running /Users/X/.ipython/profile_default/security/cluster-1648935811-e7r2.json

现在您可以使用集群 ID 定义客户端:

rc = ipp.Client(cluster_id='1648935811-e7r2')

这是启动集群后 Jupyter notebook 集群选项卡的样子:

IPython cluster

如果您从 Jupyter notebook 选项卡启动默认集群(不确定如何在命令行上执行此操作),命令 rc = ipp.Client() 也可以在没有集群的情况下工作编号。

关于python - ipyparallel 异常 : "You have attempted to connect to an IPython Cluster but no Controller could be found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45584619/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com