【问题标题】:Where is ipython/jupyter config file located inside virtual environment created using `python -m venv myvenv`?使用“python -m venv myvenv”创建的虚拟环境中的 ipython/jupyter 配置文件在哪里?
【发布时间】:2018-07-27 16:37:03
【问题描述】:

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

[编辑]
使用
python -m venv myvenv创建的虚拟环境中的 ipython/jupyter 配置文件在哪里?
我知道系统范围的配置文件类似于
/.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'

【问题讨论】:

标签: python matplotlib ipython jupyter jupyter-console


【解决方案1】:

Jupyter notebook/console,你可以这样设置后端:

import matplotlib
matplotlib.use('TkAgg')

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

【讨论】:

    【解决方案2】:

    转到您的根文件夹。

    cd ~

    ls -la

    你会看到一个 .jupyter 文件夹

    cd .jupyter

    你可以看到 jupyter_notebook_config.py

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-20
      • 2019-12-06
      • 1970-01-01
      • 2017-10-24
      • 2021-01-22
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      相关资源
      最近更新 更多