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'发布于 2018-07-28 00:41:43
在Jupyter notebook/console中,您可以像这样设置后端:
import matplotlib
matplotlib.use('TkAgg')如果您已经运行了matplotlib脚本,则必须在启动内核i/e时执行此操作,重新启动内核,并首先通过在单元中运行上述代码来设置后端。
发布于 2019-10-02 06:02:15
转到您的根文件夹。
cd ~
ls -la
您将看到一个.jupyter文件夹
cd .jupyter
你可以看到jupyter_notebook_config.py
https://stackoverflow.com/questions/51562173
复制相似问题