python - 朱皮特 : Arguments in line magic commands

标签 python jupyter

我经常使用Jupyter的cell magic命令

%%px --targets 3
#Some code

在 3 号集群上运行一些代码。使用 line 魔术命令实现相同结果的语法是什么?

我试过了

%px --targets 3 #Some code

但是不起作用

最佳答案

(未经测试)您可以将后缀与集群编号 3 相关联,如此处所述 https://ipython.org/ipython-doc/3/parallel/magics.html#multiple-active-views

因此假设您的 IPython.parallel.Client 实例名为 rc

c3 = rc[3]
c3.activate('_3')
c3.block = True

然后你就可以写

%px_3 #some code

对于线条魔法和

%%px_3 
#some code

细胞魔法。

关于python - 朱皮特 : Arguments in line magic commands,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42074012/

相关文章:

google-maps - Gmaps 无法与 Jupyter Labs 一起使用 - 错误 : No provider for: jupyter. extensions.jupyterWidgetRegistry

java - 使用自定义 header 和授权请求 HTTP rest 资源?

python - Jupyter 实验室 - dask-labextension 不起作用

jupyter-notebook - 如何在没有密码且没有 token 的情况下在本地运行Jupyter笔记本?

python - 如何使 "ctrl+Enter"在 vscode 中与 Jupyter 一起工作?

ipython - Jupyterhub终端路径变量

python - dill 转储 session : Making Jupyter-session pickle-able again

python - 为什么 pd.date_range 返回一个空序列?

python - 正则表达式:删除点之前长度为 1-3 的字母

php - 如何从网页运行python脚本?