【发布时间】:2019-08-13 11:19:23
【问题描述】:
Visual Studio Code 可以选择连接到 jupyter notebook。完成后,我可以通过单击 shift+enter(或其他快捷方式)来执行我的脚本,然后在 python 交互中会有 jupyter notebook 执行结果,例如。如果我使用 matplotlib 图,我可以在 python 交互中显示这个图。我尝试为 Visual Studio 2017 找到相同的解决方案(与 jupyter notebook 集成),根据我的示例,我想在 Visual Studio 2017 python 交互式窗口(我想它连接到 jupyter notebook)中显示我的 matplotlib 图。可能吗?这是正确的方法吗?
我不是在质疑如何在 Visual Studio 2017 中使用 IPYNB 文件,我的问题是如何将我的 python 脚本作为 jupyter notebook 执行?
如果我有像 this 这样的 python 脚本
import matplotlib.pyplot as plt
import numpy as np
def f(t):
'A damped exponential'
s1 = np.cos(2 * np.pi * t)
e1 = np.exp(-t)
return s1 * e1
t1 = np.arange(0.0, 5.0, .2)
l = plt.plot(t1, f(t1), 'ro')
plt.setp(l, markersize=30)
plt.setp(l, markerfacecolor='C0')
plt.show()
并在 Visual Studio Code 中使用 shift + Enter 执行此脚本 我在 python 交互式窗口中有我的结果图。 如果我在 Visual Studio 2017 中使用 Python Interactive 中的 Debug->Execute File 执行相同的脚本,则结果图位于 python 交互式窗口之外。在 Visual Studio 2017 中,我使用 Anaconda 5.2.0 作为 Python 环境。 如何解决这个问题?
【问题讨论】:
-
你试过用谷歌搜索
Visual Studio 2017 Jupyter吗?副本是第一个结果。它链接到A Lap Around Python in Visual Studio 2017。您是否在 Visual Studio 中安装了 Python 有效负载? -
是的,我有。可能的重复问题主要是关于使用 IPYNB 文件。然而,Lap Around Python 并不能解决 plt 的问题。显示在 anaconda 交互中。
标签: python visual-studio visual-studio-code visual-studio-2017 jupyter-notebook