1

ipython and jupyter-console have different matplotlib backends. Due to this I can't show my plots when using jupyter-console.
Both run in virtual environment on Xubuntu 16.04.

[edit]
Where is ipython/jupyter config file located inside virtual environment created using
python -m venv myvenv?
I know that system-wide configuration file is something like
/.ipython/profile_default/ipython_kernel_config.py, and I can create it running
ipython profile create. But the ipython virtual enviroment-wide configuration file? Do I even need it, isn't changing system-wide config enough?

$ 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'
kujaw
  • 313
  • 1
  • 3
  • 18
  • 1
    Possible duplicate of [Change default backend for matplotlib in Jupyter Ipython](https://stackoverflow.com/questions/48207687/change-default-backend-for-matplotlib-in-jupyter-ipython) – Mr. T Jul 27 '18 at 16:41
  • Maybe [this](https://ipython.org/ipython-doc/3/development/config.html#configuration-file-location) can help. It looks like it should at least be possible to define a new profile for the different environments. – ImportanceOfBeingErnest Jul 28 '18 at 00:06

2 Answers2

0

In Jupyter notebook/console, you can set the back end like this:

import matplotlib
matplotlib.use('TkAgg')

You must do this upon starting the kernel i/e, if you've already run a matplotlib script, restart the kernel, and set the backend first by running the above code in a cell.

Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
0

Go to your root folder.

cd ~

ls -la

you will see a .jupyter folder

cd .jupyter

you can see jupyter_notebook_config.py

Harsha Vardhan
  • 119
  • 1
  • 12