【问题标题】:How to connect to an existing Jupyter Notebook kernel and inspect variables using the Variable explorer?如何连接到现有的 Jupyter Notebook 内核并使用变量资源管理器检查变量?
【发布时间】:2019-08-22 10:23:49
【问题描述】:

如果我有一个通过 Jupyter Notebook 运行的内核,我可以使用 Options > Connect to an exisisting kernel > Browse 从 Spyder 轻松连接到它。现在我可以通过运行df 来访问 Jupyter 内核并查看数据帧或任何其他变量:

Jupyter sn-p:

#imports
import numpy as np
import pandas as pd

# Some sample data
np.random.seed(1234)
df = pd.DataFrame({'A1':np.random.normal(10, 1, 8),
                   'B1':np.random.normal(20, 2, 8)})

Spyder sn-p:

df

# output:
          A1         B1
0  10.471435  20.031393
1   8.809024  15.514630
2  11.432707  22.300071
3   9.687348  21.983892
4   9.279411  21.906648
5  10.887163  15.957490
6  10.859588  19.331845
7   9.363476  20.004237

但是为什么 Spyder 的 Variable Explorer 中没有数据框呢?

【问题讨论】:

    标签: python jupyter-notebook spyder


    【解决方案1】:

    此处是 Spyder 维护者)发生这种情况是因为笔记本创建的内核不具备在我们的变量资源管理器中显示其命名空间所需的功能。

    抱歉,目前没有简单的解决方法。

    【讨论】:

    • 感谢您的回答!我可能只是在这里暴露了我缺乏基本的 Python 知识,但是如何使用例如 print(df) 访问变量同时没有在变量资源管理器中显示命名空间的功能?
    • 因为默认的 notebook 内核不是 Spyder 内核(是的,我们的内核是特殊的,即它们有几个可以与 Spyder 一起工作的附加内容),它们无法与 Spyder 通信以告诉它如何以及何时更新变量资源管理器。
    猜你喜欢
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    • 2017-03-15
    • 1970-01-01
    • 2022-10-25
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    相关资源
    最近更新 更多