1

ipython 和 jupyter-console 有不同的 matplotlib 后端。因此,我在使用 jupyter-console 时无法显示我的情节。
两者都在 Xubuntu 16.04 的虚拟环境中运行。

[编辑]
使用创建的虚拟环境中的 ipython/jupyter 配置文件在哪里
python -m venv myvenv
我知道系统范围的配置文件类似于
/.ipython/profile_default/ipython_kernel_config.py,我可以创建它运行
ipython profile create。但是 ipython 虚拟环境范围的配置文件呢?我什至需要它,更改系统范围的配置还不够吗?

$ ipython
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import matplotlib

In [2]: matplotlib.get_backend()
Out[2]: 'TkAgg'



$ jupyter-console
Jupyter console 5.2.0

Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.


In [1]: import matplotlib

In [2]: matplotlib.get_backend()
Out[2]: 'module://ipykernel.pylab.backend_inline'
4

2 回答 2

0

转到您的根文件夹。

光盘~

ls -la

你会看到一个 .jupyter 文件夹

光盘.jupyter

你可以看到 jupyter_notebook_config.py

于 2019-10-01T22:02:15.433 回答
0

Jupyter notebook/console中,您可以像这样设置后端:

import matplotlib
matplotlib.use('TkAgg')

如果您已经运行了 matplotlib 脚本,则必须在启动内核 i/e 时执行此操作,重新启动内核,并首先通过在单元格中运行上述代码来设置后端。

于 2018-07-27T16:41:43.300 回答