Graphs are no longer displayed in the output of Jupyter Notebook cells (on Visual Studio Code). How to solve this problem?

huangapple go评论67阅读模式
英文:

Graphs are no longer displayed in the output of Jupyter Notebook cells (on Visual Studio Code). How to solve this problem?

问题

自从昨天开始,在我运行在Visual Studio Code上编写的Jupyter笔记本中的Python代码时,单元格输出中不再显示图形。相反,只显示一行文本。例如:<IPython.core.display.Javascript object>。

我认为我在Visual Studio Code的设置中不知不觉地更改了一些内容。然而,我找不到任何方法来解决这个问题。

我已经多次重新启动了Visual Studio Code和我的计算机,并尝试了不同的内核,但什么都没有改变。

我尝试通过点击单元格输出左侧的“更改呈现”然后选择“image/png”作为“mimetype”来解决这个问题,但是我无法选择“image”,因为它不在“mimetype”列表中。
一个不再显示图形的单元格输出示例。

在出现此问题之前,这段代码是有效的。

非常感谢您提前的帮助!

英文:

Since yesterday no more graph appears in the cell output when I run my Python codes written as Jupyter notebook on Visual Studio Code. Instead, only one line of text is displayed. For example :
<IPython.core.display.Javascript object>.

I think I changed something without realizing it in the settings of Visual Studio Code. However, I couldn't find anywhere how to solve this problem.

I restarted Visual Basic and my computer several times and used different kernels, but nothing changed.

I tried to solve the problem by clicking on "change presentation" left to the cell output and then to elect "image/png" as "mimetype", but I can't select "image" as it is not in the list of "mimetype".
Example of a cell output where the graph is no longer displayed.

The code was working before this issue.

Thank you very much in advance for your help!

答案1

得分: 0

似乎你的ipython出了一些问题。

你可以尝试在终端中使用以下命令重新安装ipython:

pip uninstall ipython
pip install ipython
英文:

It seems that there's something wrong with your ipython.

You can try to reinstall ipython by the following command in terminal:

pip uninstall ipython
pip install ipython

答案2

得分: 0

问题出现在我的代码开头的“%matplotlib notebook”语句。

经过一些调查,我发现Visual Studio Code不支持“%matplotlib notebook”语句。
这个语句在Jupyter笔记本中用于启用交互式图形功能,例如使用鼠标在空间中移动3D图形的能力。

要解决这个问题,只需在Visual Studio Code中使用“%matplotlib widget”代替“%matplotlib notebook”。

英文:

The problem came from the "%matplotlib notebook" statement at the beginning of my code.

After doing some investigation, it occurred to me that the "%matplotlib notebook" statement is not supported by Visual Studio Code.
This statement is used in jupyter notebooks to enable interactive graphics features such as the ability to move a 3D graphic in space with the mouse.

To solve this problem, just use "%matplotlib widget" instead of "%matplotlib notebook" on Visual Studio Code.

huangapple
  • 本文由 发表于 2023年5月29日 20:39:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76357465.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定